background image

44

        }   

45

        rs.close();   

46

        ps.close();   

47

    }   

48

   

49

    public static void main(String[] args)   

50

    {   

51

        OracleJdbcTest test = new OracleJdbcTest();   

52

        test.init();   

53

        test.fetch();   

54

    }   

55

}  

6.  Java util.Date 转成 sql.Date

56

java.util.Date utilDate = new java.util.Date();   

57

java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());  

7. 使用 NIO 进行快速的文件拷贝

58

public static void fileCopy( File in, File out )   

59

            throws IOException   

60

    {   

61

        FileChannel inChannel = new FileInputStream( in ).getChannel();   

62

        FileChannel outChannel = new FileOutputStream( out ).getChannel();   

63

        try  

64

        {   

65

//          inChannel.transferTo(0, inChannel.size(), outChannel);      // original -- apparently 

has trouble copying large files on Windows   

66

   

67

            // magic number for Windows, 64Mb - 32Kb)   

68

            int maxCount = (64 * 1024 * 1024) - (32 * 1024);   

69

            long size = inChannel.size();   

70

            long position = 0;