Java IOѧϰ±Ê¼Ç£º×Ö½ÚÁ÷
Java IOѧϰ±Ê¼Ç£º×Ö½ÚÁ÷
×Ö½ÚÁ÷ÊÇ×î»ù±¾µÄÁ÷£¬ÎļþµÄ²Ù×÷¡¢ÍøÂçÊý¾ÝµÄ´«ÊäµÈµÈ¶¼ÒÀÀµÓÚ×Ö½ÚÁ÷¡£¶ø×Ö·ûÁ÷³£³£ÓÃÓÚ¶ÁÈ¡Îı¾ÀàÐ͵ÄÊý¾Ý»ò×Ö·û´®Á÷µÄ²Ù×÷µÈµÈ¡£
¹ØÓÚ×Ö½ÚÁ÷µÄAPI£¬Ã»Ê²Ã´ºÃ˵µÄ£¬¿´¿´¾ÍÖªµÀÁË¡£ÕâÀïÌô¼¸¸ö¹Ø¼üµã£º
Ò»¡¢InputStreamµÄAPI
1¡¢public int read()
´ÓÊäÈëÁ÷¶ÁÈ¡ÏÂÒ»¸öÊý¾Ý×Ö½Ú¡£·µ»Ø 0 µ½ 255 ·¶Î§ÄÚµÄ int ×Ö½ÚÖµ¡£Èç¹ûÒòÒѵ½´ïÁ÷ĩβ¶øûÓпÉÓõÄ×Ö½Ú£¬Ôò·µ»ØÖµ -1¡£
2¡¢public int read(byte[] b)
´ÓÊäÈëÁ÷ÖжÁÈ¡Ò»¶¨ÊýÁ¿µÄ×Ö½Ú²¢½«Æä´æ´¢ÔÚ»º³åÇøÊý×é b ÖС£ÒÔÕûÊýÐÎʽ·µ»Øʵ¼Ê¶ÁÈ¡µÄ×Ö½ÚÊý¡£Èç¹ûÒòΪÁ÷λÓÚÎļþĩβ¶øûÓпÉÓõÄ×Ö½Ú£¬Ôò·µ»ØÖµ -1£»·ñÔò£¬ÖÁÉÙ¿ÉÒÔ¶ÁÈ¡Ò»¸ö×Ö½Ú²¢½«Æä´æ´¢ÔÚ b ÖС£´Ë·½·¨µÈͬÓÚread(b, 0, b.length)
3¡¢public int read(byte[] b, int off, int len)
½«ÊäÈëÁ÷ÖÐ×î¶à len ¸öÊý¾Ý×Ö½Ú¶ÁÈë×Ö½ÚÊý×é¡£³¢ÊÔ¶ÁÈ¡¶à´ï len ×Ö½Ú£¬µ«¿ÉÄܶÁÈ¡½ÏÉÙÊýÁ¿¡£ÒÔÕûÊýÐÎʽ·µ»Øʵ¼Ê¶ÁÈ¡µÄ×Ö½ÚÊý¡£Èç¹ûÓÉÓÚÒѵ½´ïÁ÷ĩβ¶ø²»ÔÙÓÐÊý¾Ý£¬Ôò·µ»Ø -1¡£
²ÎÊý£º
b - ¶ÁÈëÊý¾ÝµÄ»º³åÇø¡£
off - ÔÚÆ䴦дÈëÊý¾ÝµÄÊý×é b µÄ³õʼƫÒÆÁ¿¡£
len - Òª¶ÁÈ¡µÄ×î´ó×Ö½ÚÊý¡£
¶þ¡¢OutputStreamµÄAPI
1¡¢public void write(int b)
½«Ö¸¶¨µÄ×Ö½ÚдÈë´ËÊä³öÁ÷¡£write µÄ³£¹æж¨ÊÇ£ºÏòÊä³öÁ÷дÈëÒ»¸ö×Ö½Ú¡£ÒªÐ´ÈëµÄ×Ö½ÚÊDzÎÊý b µÄ°Ë¸öµÍλ¡£b µÄ 24 ¸ö¸ß뽫±»ºöÂÔ¡£
2¡¢public void write(byte[] b)
½« b.length ¸ö×Ö½Ú´ÓÖ¸¶¨µÄ×Ö½ÚÊý×éдÈë´ËÊä³öÁ÷¡£write(b) µÄ³£¹æж¨ÊÇ£ºÓ¦¸ÃÓëµ÷Óà write(b, 0, b.length) µÄЧ¹ûÍêÈ«Ïàͬ¡£
3¡¢public void write(byte[] b,
int off,
int len)
½«Ö¸¶¨×Ö½ÚÊý×éÖдÓÆ«ÒÆÁ¿ off ¿ªÊ¼µÄ len ¸ö×Ö½ÚдÈë´ËÊä³öÁ÷¡£write(b, off, len) µÄ³£¹æж¨ÊÇ£º½«Êý×é b ÖеÄijЩ×Ö½Ú°´Ë³ÐòдÈëÊä³öÁ÷£»ÔªËØ b[off] ÊǴ˲Ù×÷дÈëµÄµÚÒ»¸ö×Ö½Ú£¬b[off+len-1] ÊǴ˲Ù×÷дÈëµÄ×îºóÒ»¸ö×Ö½Ú¡£
²ÎÊý£º
b - Êý¾Ý¡£
off - Êý¾ÝÖеijõʼƫÒÆÁ¿¡£
len - ҪдÈëµÄ×Ö½ÚÊý¡£
4¡¢public void flush()
ˢдËÊä³öÁ÷²¢Ç¿ÖÆд³öËùÓлº³åµÄÊä³ö×Ö½Ú¡£flush µÄ³£¹æж¨ÊÇ£ºÈç¹û´ËÊä³öÁ÷µ
Ïà¹ØÎĵµ£º
²»¹ÜÄãÊÇÐÂÊÖ»¹ÊÇÀÏÄñ£¬ÔÚ³ÌÐòÖжÁÈ¡×ÊÔ´Îļþ×Ü»áÓöµ½Ò»Ð©ÕÒ²»µ½ÎļþµÄÎÊÌ⣬ÕâÓëJavaµ×²ãµÄʵÏÖÓйأ¬²»ÄÜËãbug£¬Ö»Òª·½·¨µÃµ±£¬ÎÊÌ⻹ÊÇ¿ÉÒÔ½â¾öµÄ¡£
ÏîÄ¿µÄÎļþ¼Ð½á¹¹£º
repathtest
©À©¤src
©¦ ©¸©¤com
©¦ &nb ......
½ñÌì¿´ÁËһλǰ±²µÄÎÄÕÂhttp://blog.csdn.net/psyl/archive/2010/01/24/5250562.aspx
µÚÒ»Ìâ¾Í²»»á¡£°¥£¬Ôΰ¡¡£»ù´¡Ì«²î£¬ÐèÒª¼ÓÇ¿¡£
GoogleÁËһϠhttp://www.ibm.com/developerworks/cn/java/l-javaassertion/index.html ÕâƪÎÄÕ½éÉÜassertion,¸Ð¾õ²»´í£¬×ªÏµØÖ·¡£
SpringÒ²ÌṩÁ˶ÏÑԵŦÄÜ
org.springframew ......
1. ³éÏó
³éÏó¾ÍÊǺöÂÔÒ»¸öÖ÷ÌâÖÐÓ뵱ǰĿ±êÎ޹صÄÄÇЩ·½Ã棬ÒÔ±ã¸ü³ä·ÖµØ×¢ÒâÓ뵱ǰĿ±êÓйصķ½Ãæ¡£³éÏó²¢²»´òËãÁ˽âÈ«²¿ÎÊÌ⣬¶øÖ»ÊÇÑ¡ÔñÆäÖеÄÒ»²¿·Ö£¬ÔÝʱ²»Óò¿·Öϸ½Ú¡£³éÏó°üÀ¨Á½¸ö·½Ã棬һÊǹý³Ì³éÏ󣬶þÊÇÊý¾Ý³éÏó¡£
2. ¼Ì³Ð
¼Ì³ÐÊÇÒ»ÖÖÁª½áÀàµÄ²ã´ÎÄ£ÐÍ£¬²¢ÇÒÔÊÐíºÍ¹ÄÀøÀàµÄÖØÓã¬ËüÌṩÁËÒ»ÖÖÃ÷È· ......
Ò»¡¢Ï̸߳ÅÊö
Ïß³ÌÊdzÌÐòÔËÐеĻù±¾Ö´Ðе¥Ôª¡£µ±²Ù×÷ϵͳ(²»°üÀ¨µ¥Ï̵߳IJÙ×÷ϵͳ£¬Èç΢ÈíÔçÆÚµÄDOS)ÔÚÖ´ÐÐÒ»¸ö³ÌÐòʱ£¬»áÔÚϵͳÖн¨Á¢Ò»¸ö½ø³Ì£¬¶øÔÚÕâ¸ö½ø³ÌÖУ¬±ØÐëÖÁÉÙ½¨Á¢Ò»¸öỊ̈߳¨Õâ¸öÏ̱߳»³ÆΪÖ÷Ị̈߳©À´×÷ΪÕâ¸ö³ÌÐòÔËÐеÄÈë¿Úµã¡£Òò´Ë£¬ÔÚ²Ù×÷ϵͳÖÐÔËÐеÄÈκγÌÐò¶¼ÖÁÉÙÓÐÒ»¸öÖ÷Ï̡߳£
½ø³ÌºÍÏß³ÌÊÇÏÖ´ú²Ù× ......
ÔÚËãÊõÔËËã·û²¿·Ö£¬ÐèÒªÌرð×¢ÒâµÄÒ»¸öÓï·¨ÏÖÏóÊÇ“½úÉý”¡£½úÉýÖ¸µÍÓÚintµÄ3ÖÖÊý×ÖÀàÐÍ(byte¡¢shortºÍchar)½øÐÐËãÊõÔËËãºó£¬½á¹û»á×Ô¶¯ÌáÉý³ÉintÀàÐÍ¡£Ê¾Àý´úÂëÈçÏ£º
byte b1 = 10;
& ......