javaѧϰС¼Ç¶þ
×î½üÒ»Ö±¾À½áÓÚJavaµÄIOÖУ¬¸Õ¿ªÊ¼¿´µÄһͷÎíË®£¬¸÷ÖÖStream£¬¸÷ÖÖReader£¬¸÷ÖÖBuffer¡£headache£¡
1£¬×ܵÄÀ´Ëµ¾Í°üÀ¨InputStream ºÍ OutputStream Á½¸ö£¬¾ßÌåÓ¦¸ÃÓò»µ½£¬¶¼ÊÇÓÃËûÃǵÄÅÉÉúÀà¡£
2£¬File ÀàµÄObject ¿ÉÒÔÊÇÒ»¸öÎļþ£¬Ò²¿ÉÒÔÊÇÒ»¸ödirectory/path¡£
3£¬Stream ÊÇÃæÏòlow-levelµÄ£¬¶øReader/WriterÊÇÃæÏòcharacterµÄ¡£
4£¬Whenever you want use readLine(),use BufferedReader¡£Other than this, DataInputStream is preferred choice¡£DataInputStream is offen used for getting primitives¡£
5,Old IO ²»¶à˵ÁË¡£New IOÓ¦¸Ã˵»á±È½Ï³£Óã¬NIO Ö÷Òª°üÀ¨Á½¸ö¶«¶«£¬·Ç³£ÖØÒª£¬Ò»¸öÊÇchannel£¬Ò»¸öÊÇByteBuffer¡£½«Îļþ»òÕßÆäËüÊäÈëÁ÷¶¼×ª»¯È¥Channel£¬¶ÔÓÚÎļþÓÃFileInputStream().getChannel()£¬»òÕßFileOutputStream().getChannel(),»òÕßRandomAccessFile().getChannel()£¬¶ÔÓÚSocket Ò²¿ÉÒÔÓöÔÓ¦µÄ·½·¨´¦Àí³ÉChannel¡£ByteBufferÖ÷ÒªÃæÏòbytes£¬Ö÷Òª·½·¨ÊÇallocate()·ÖÅä¿Õ¼ä,filp()²Ã¼ô½«capacityÉèÖõ½limit,clear()ÖØÖÃ,array(),hasRemaining()¼ì²épositionºÍlimitÖ®¼äÊÇ·ñ»¹ÓÐelementsµÈ¡£½«channelµÄÄÚÈݶÁÈëbufferÓÃfc.read(buffer),½«bufferдÈëchannelÓÃfc.write(buffer).
6£¬¶ÔÓÚByteBufferÓиöstatic·½·¨wrap,¿ÉÒÔÓÃÓÚ½«Ä³string.getBytes(),´¦Àí³Ébyte[]¡£ByteBffer»¹ÊÇlow-levelµÄ£¬¿ÉÒÔÓÃCharBffer£¬IntBuffer,DoubleBufferµÈÀ´×¥»¯ÎªÒ×ÓÚ´¦ÀíµÄ¡£Õ⼸¸ö×ÓÀàÕý³£constructorʱ£¬¶¼ÊÇHeapÐ͵ģ¬¶¼¿ÉÒÔÓÃarray()·½·¨£¬ÒªÊÇByteBufferʹÓÃasCharBuffer(),asIntBuffer£¬µÈת»¯À´µÄ£¬¾Í²»ÄÜÓÃarray()ÁË¡£HeapÐ͵ģ¬²»»á°´ÕÕ¶ÔÓ¦ÀàÐÍ»®·ÖÇøÓò£¬Ã¿´ÎʹÓÃʱ£¬°´¶ÔÓ¦ÀàÐÍÔö¼Ópos¡£¶øByteBufferAsÐ͵ģ¬¾Í»á°´ÕÕ¶ÔÓ¦µÄÀàÐÍ£¬½«size»®·Ö³ÉµÈ´óСµÄ£¬Ã¿´Îpos+1¡£
7£¬¶ÔÓÚCharBufferµÈµÄ£¬¾Í¿ÉÒÔÓÃput(),get()µÈÏÔʾµÄдÈë»ò¶ÁÈ¡Êý¾Ý¡£
8£¬char¡¢short 2bytes£»int float 4bytes£»double long 8bytes¡£
Ïà¹ØÎĵµ£º
ListµÄÓ÷¨
List°üÀ¨List½Ó¿ÚÒÔ¼°List½Ó¿ÚµÄËùÓÐʵÏÖÀà¡£ÒòΪList½Ó¿ÚʵÏÖÁËCollection½Ó¿Ú£¬ËùÒÔList½Ó¿ÚÓµÓÐCollection½Ó¿ÚÌṩµÄËùÓг£Ó÷½·¨£¬ÓÖÒòΪListÊÇÁбíÀàÐÍ£¬ËùÒÔList½Ó¿Ú»¹ÌṩÁËһЩÊʺÏÓÚ×ÔÉíµÄ³£Ó÷½·¨£¬Èç±í1Ëùʾ¡£
±í1 List½Ó¿Ú¶¨ÒåµÄ³£Ó÷½·¨¼°¹¦ÄÜ
´Ó±í1¿ÉÒÔ¿´³ö£¬List½Ó¿ÚÌṩµÄÊʺÏÓÚ×ÔÉíµÄ ......
Ê×ÏÈÏÂÔØopenjdk´úÂë°ü£¬http://download.java.net/openjdk/jdk7/£¬ÕâÀïÏÂÔصÄÊǵ±Ç°µÄ×îа汾b94£¬openjdk-7-ea-src-b94-20_may_2010.zip¡£ ½âѹËõopenjdk-7-ea-src-b94-20_may_2010.zipµ½D:\JVM¡£ÔÚD:\JVM\openjdkÏ´ò¿ªREADME-builds.htmlÎļþ¡£° ......
Server¶Ë:
package test.bwl;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket; &nbs ......
¼òµ¥Ð´ÁËÒ»¸ö£¬Ö»ÊÇÑéÖ¤Ò»ÏÂÊý¾ÝÁ÷»¥Ïà´«ËÍ£¬¾ßÌ幦ÄÜ¿ÉÒÔ×Ô¼º¼Ótest.java ¿Í»§¶Ë£º¶ÁÈ¡1.xmlÎļþ·¢Ë͸øDataServer£¨servlet£©,¶ÁÈ¡servlet·µ»ØµÄÄÚÈÝDataServer.java ·þÎñÆ÷servlet:¶ÁÈ¡test·¢Ë͵ÄxmlÄÚÈÝ£¬°ÑÄÚÈÝÔÙ·µ»Ø¸ø¿Í»§¶Ë¡£
/**
* * ¿Í»§¶Ë£¬· ......