Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Java 7ÐÂI/OÌØÐÔ½âÎö


Java 7ÌṩÁËÒ»¸öÐÂAPI·ÃÎÊÎļþϵͳ£¬µ«³ý´ËÖ®Í⣬JSR 203(NIO.2)»¹°üº¬ÆäËüºÜ¶àÐÂÌØÐÔ£¬Õâ¸öа汾µÄÈ·ÐÂÔöÁ˺ܶà¸ÄÉÆI/O±à³ÌµÄÀ࣬±¾ÎĽ«»á½éÉÜÏÂÃæµÄÐÂÌØÐÔ£º
· SeekableByteChannel£ºËæ»ú·ÃÎÊͨµÀ;
· MulticastChannel£ºÔÊÐíIP¶à²¥µÄͨµÀ;
· NetworkChannel£ºÐµÄÍøÂçͨµÀ³¬¼¶½Ó¿Ú;
· Òì²½I/O API£ºÐµÄAPIʹI/O²Ù×÷¿ÉÒÔÒì²½½øÐС£
SeekableByteChannel
Ê×ÏÈ£¬Java 7°üÀ¨ÐµÄByteChannel – SeekableByteChannel£¬Õâ¸öͨµÀά»¤µ±Ç°µÄλÖã¬Äã¿ÉÒÔ¶Áд¸ÃλÖ㬲¢ÔÊÐíËæ»ú·ÃÎÊ¡£Ê¹ÓÃÕâ¸öÀàÐ͵ÄͨµÀ£¬Äã¿ÉÒÔÌí¼Ó¶à¸öÏ̶߳Á/дÔÚ ²»Í¬Î»ÖÃÏàͬµÄÏ̡߳£
 
SeekableByteChannel channel1 = Paths.get("Path to file").newByteChannel();//Simply READ
SeekableByteChannel channel2 = Paths.get("Path to file").newByteChannel(StandardOpenOption.READ, StandardOpenOption.WRITE);//READ and WRITE
Äã¿É ÒÔʹÓÃÏÂÃæÕâЩ·½·¨²Ù×÷λÖúÍͨµÀµÄ´óС¡£
· long position()£º·µ»ØÄ¿Ç°µÄλÖÃ;
· long size()£º·µ»ØͨµÀÁ¬½ÓʵÌåµÄµ±Ç°´óС£¬ÈçͨµÀÁ¬½ÓµÄÎļþ´óС;
· position(long newPosition)£ºÒƶ¯µ±Ç°Î»Öõ½Ä³¸öµØ·½;
· truncate(long size)£º¸ù¾Ý¸ø¶¨´óС½Ø¶ÏʵÌå¡£
position()ºÍtruncate()·½·¨¼òµ¥µØ·µ»Øµ±Ç°Í¨µÀ£¬ÔÊÐíÁ´Ê½µ÷Óá£
ÏÖÔÚFileChannelʵÏÖÁËеĽӿڣ¬Ê¹ ÓÃËùÓÐFileChannelÄ㶼¿ÉÒÔʵÏÖËæ»ú·ÃÎÊ£¬µ±È»Äã¿ÉÒÔÓÃËü¶ÁÈ¡Ò»¸öÎļþ£º
 
SeekableByteChannel channel = null;
try {
channel = Paths.get("Path to file").newByteChannel(StandardOpenOption.READ);
ByteBuffer buf = ByteBuffer.allocate(4096);
System.out.println("File size: " + channel.size());
String encoding = System.getProperty("file.encoding");
while (channel.read(buf) > 0) {
buf.rewind();
byte[] bytearr = new byte[bytebuff.remaining()];
buf.get(bytearray);
System.out.print(new String(bytearray));
buf.flip();
System.out.println("Current position : " + channel.position());
}
} catch (IOException e) {
System.out.println("Expection when reading : " + e.g


Ïà¹ØÎĵµ£º

ÍƼöÒ»¿îJava·´±àÒëÆ÷£¬±È½ÏºÃÓÃ

 ÍƼöÒ»¿îJava·´±àÒëÆ÷£¬Ò²Ê¹ÓÃÁËͦ¾ÃµÄÁË£¬¸Ð¾õ»¹ÊǺܺÃÓ㬾ÍÄóöºÍ´ó¼Ò·ÖÏíһϡ£
Õâ¿î·´±àÒëÆ÷½Ð "Java Decompiler", ÓÉ Pavel Kouznetsov¿ª·¢£¬Ä¿Ç°×îа汾Ϊ0.2.5.
ËüÓÉ C++¿ª·¢£¬²¢ÇÒ¹Ù·½¿ÉÒÔÏÂÔØ windows¡¢linuxºÍÆ»¹ûMac OsÈý¸öƽ̨µÄ¿ÉÖ´ÐгÌÐò¡£
   ±¾ÈËÖ®ËùÒÔÈÏΪËü»¹²»´í£¬ÊÇÆäÓÐÏÂÃ漸¸ö¹ ......

JavaÁ¬½Ósqlite

1.È¥ÍøÕ¾http://files.zentus.com/sqlitejdbc/ÏÂÔØsqlitejdbc.¸ù¾Ý×ÔÒÑÐèÒª£¬ÏÂÔØsqlitejdbc.(sqlitejdbcÓÐÁ½¸ö°æ±¾£¬Ò»ÖÖÊÇpureµÄÒ»ÖÖÊÇnativeµÄ¡£nativeµÄËٶȿ졣Ëü·ÅÔÚ**-bin.tgzÀï¡£ÎÒϵľÍÊÇÕâÖÖsqlitejdbc-v056-bin.tgz£©
2. ÏÂÔغó½âѹsqlitejdbc-v056-bin.tg £¬ÓÐÒÔϼ¸¸öÎļþ£º libsqlitejdbc.so£¬sqlitejdbc.d ......

Óë Josh Bloch ̽ÌÖ Java δÀ´

×÷Õß




Josh Long




ÒëÕß

ËÎçâ

·¢²¼ÓÚ
2010Äê5ÔÂ5ÈÕ ÏÂÎç9ʱ7·Ö

Josh BlochÔÚSun¹«Ë¾¶àÄêΪJavaƽ̨×÷³öÁ˽ܳö¹±Ï×£¨Èç¹ûÄãÓùýJava
Collections¿ò¼Ü¾Í»áÁ˽âÕâÒ»µã£©£¬ÏÖÔÚGoogle¾ÍÖ°£¬ÊÇ»ñ½±Í¼Ê顶Effective ......

¡¾×ª¡¿JavaÖÐtoString()·½·¨

1£®toString£¨£©·½·¨
ObjectÀà¾ßÓÐÒ»¸ötoString()·½·¨£¬Äã´´½¨µÄÿ¸öÀ඼»á¼Ì³Ð¸Ã·½·¨¡£Ëü·µ»Ø¶ÔÏóµÄÒ»¸öString±íʾ£¬²¢ÇÒ¶ÔÓÚµ÷ÊԷdz£ÓаïÖú¡£È»¶ø¶ÔÓÚĬÈϵÄtoString()·½·¨ÍùÍù²»ÄÜÂú×ãÐèÇó£¬ÐèÒª¸²¸ÇÕâ¸ö·½·¨¡£
toString£¨£©·½·¨½«¶ÔÏóת»»Îª×Ö·û´®¡£¿´ÒÔÏ´úÂ룺
package sample;
class Villain {
  &nb ......

ÿ¸öÏîÄ¿ÖУ¬Äã²»µÃ²»ÖªµÄ11¸öJavaµÚÈý·½Àà¿â

µ¥Ôª²âÊÔ
1.
DBUnit
DBunitÊÇÒ»¸ö»ùÓÚjunitÀ©Õ¹µÄÊý¾Ý¿â²âÊÔ¿ò¼Ü¡£ËüÌṩÁË´óÁ¿µÄÀà¶ÔÓëÊý¾Ý¿âÏà¹ØµÄ²Ù×÷½øÐÐÁ˳éÏóºÍ·â×°¡£
2.MOckito
MockitoÊÇÒ»¸öÕë¶ÔJavaµÄmocking¿ò¼Ü¡£Äã¿ÉÒÔʹÓüò½àµÄAPI±àд³öƯÁÁµÄ²âÊÔ¡£
3.Hamcrest Matchers
Hamcrest ÊÇÒ»¸ö²âÊÔ¸¨Öú¹¤¾ß£¬ÌṩÁËÒ»Ì×ͨÓõÄÆ¥Åä·û Matcher£¬Áé»îʹÓÃÕâÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ