JavaÖÐI/O³õ̽
JavaÖÐI/O³õ̽
ʵÀý£º¶ÁÈ¡Îļþtest.Txt
´úÂ룺
try {
FileReader fReader=new FileReader("c:\\java\\test.txt");
BufferedReader bReader=new BufferedReader(fReader);
while(true) {
String temp=bReader.readLine();
if(temp==null)
break;
System.out.println(temp);
}
}
catch (IOException e) {
e.printStackTrace();
}
½âÎö£º¶ÁÈ¡Îı¾ÎļþµÄÄÚÈÝͨ³£²ÉÓÃ×Ö·ûÁ÷FileReaderÀ´ÊµÏÖ£¬FileReaderÅÉÉú×ÔInputStreamReader,InputStreamReader ÊÇ×Ö½ÚÁ÷ͨÏò×Ö·ûÁ÷µÄÇÅÁº£ºËüʹÓÃÖ¸¶¨µÄ charset ¶ÁÈ¡×Ö½Ú²¢½«Æä½âÂëΪ×Ö·û¡£ËüʹÓõÄ×Ö·û¼¯¿ÉÒÔÓÉÃû³ÆÖ¸¶¨»òÏÔʽ¸ø¶¨£¬»òÕß¿ÉÒÔ½ÓÊÜƽ̨ĬÈϵÄ×Ö·û¼¯¡£ÎªÁË´ïµ½×î¸ßЧÂÊ£¬¿ÉÒª¿¼ÂÇÔÚ BufferedReader ÄÚ°ü×° InputStreamReader¡£
ÀýÈ磺BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
¼òµ¥µã˵£¬¶ÁÈ¡Îı¾Í¨³£Ê¹ÓÃBufferReader£¬¸ÃÀà±È½Ï³ÉÊ죬×Ö·ûÁ÷µÄÉϲ㣬¼òµ¥ÊµÓá£
***Java IO µÄÒ»°ãʹÓÃÔÔò £º
Ò»¡¢°´Êý¾ÝÀ´Ô´£¨È¥Ïò£©·ÖÀࣺ
1 ¡¢ÊÇÎļþ£º FileInputStream, FileOutputStream, ( ×Ö½ÚÁ÷ )FileReader, FileWriter( ×Ö·û )
2 ¡¢ÊÇ byte[] £º ByteArrayInputStream, ByteArrayOutputStream( ×Ö½ÚÁ÷ )
3 ¡¢ÊÇ Char[]: CharArrayReader, CharArrayWriter( ×Ö·ûÁ÷ )
4 ¡¢ÊÇ String: StringBufferInputStream, StringBufferOuputStream ( ×Ö½ÚÁ÷ )StringReader, StringWriter( ×Ö·ûÁ÷ )
5 ¡¢ÍøÂçÊý¾ÝÁ÷£º InputStream, OutputStream,( ×Ö½ÚÁ÷ ) Reader, Writer( ×Ö·ûÁ÷ )
¶þ¡¢°´ÊÇ·ñ¸ñʽ»¯Êä³ö·Ö£º
1 ¡¢Òª¸ñʽ»¯Êä³ö£º PrintStream, PrintWriter
Èý¡¢°´ÊÇ·ñÒª»º³å·Ö£º
1 ¡¢Òª»º³å£º BufferedInputSt
Ïà¹ØÎĵµ£º
ʹÓÃJava ME¼¼Êõ¿ª·¢ÊÖ»úÃÜÂë¹ÜÀíÈí¼þ
³ÂÔ¾·å
ÕªÒª£ºJava ME¼¼ÊõÊÇ3G¿ª·¢Ö÷Á÷µÄ¼¼ÊõÖ®Ò»£¬±¾ÎĽ«Í¨¹ýϵͳµÄ·½Ê½½éÉÜÈçºÎʹÓÃJava ME¼¼Êõ¿ª·¢ÃÜÂë¹ÜÀíÈí¼þ£¬Ê¹´ó¼ÒÄܹ»Í¨¹ý¸ÃÎÄÕ¿ìËÙÊìϤJava ME¼¼Êõ£¬½øÈë3GÒƶ¯³ÌÐò¿ª·¢µÄ´óÃÅ£¡
¹Ø¼ü×Ö£ºJava ME ÊÖ»ú ÃÜÂë ¹ÜÀí ¼Ç¼´æ´¢
......
1¡¢set¼¯ºÏÊÇ×î¼òµ¥µÄÒ»ÖÖ¼¯ºÏ£¬¼¯ºÏÖв»°´Ö¸¶¨µÄ·½Ê½ÅÅÐò£¬²¢ÇÒûÓÐÖظ´¶ÔÏó¡£
2¡¢set½Ó¿ÚÖ÷ÒªÓÐÁ½¸öʵÏÖÀࣺHashSetºÍTreeSet
(1)HashSet:ÊÇ°´ÕÕ¹þÏ£Ëã·¨À´½øÐдæÈ¡¼¯ºÏÖеĶÔÏ󣬴æÈ¡µÄËٶȱȽϿ졣
(2)TreeSet£ºÊµÏÖÁËSortedSet½Ó¿Ú£¬¾ßÓÐÅÅÐòµÄ¹¦ÄÜ¡£
3¡¢HashSetÀàÊÇ°´ÕÕ¹þÏ£Ëã·¨À´´æÈ¡ ......
1.1 ²»ÓÃnew¹Ø¼ü´Ê´´½¨ÀàµÄʵÀý
ÓÃnew¹Ø¼ü´Ê´´½¨ÀàµÄʵÀýʱ£¬¹¹Ô캯ÊýÁ´ÖеÄËùÓй¹Ô캯Êý¶¼»á±»×Ô¶¯µ÷Óᣵ«Èç¹ûÒ»¸ö¶ÔÏóʵÏÖÁËCloneable½Ó¿Ú£¬ÎÒÃÇ¿ÉÒÔµ÷ÓÃËüµÄclone()·½·¨¡£clone()·½·¨²»»áµ÷ÓÃÈκÎÀ๹Ô캯Êý¡£
ÔÚʹÓÃÉè¼Æģʽ£¨Design Pattern£©µÄ³¡ºÏ£¬Èç¹ûÓÃFactoryģʽ´´½¨¶ÔÏó£¬Ôò¸ÄÓÃclone()·½·¨´´½¨Ðµ ......
java.util Öеļ¯ºÏÀà°üº¬ Java ÖÐijЩ×î³£ÓõÄÀà¡£ ×î³£Óõļ¯ºÏÀàÊÇ List ºÍ Map¡£ List µÄ¾ßÌåʵÏÖ°üÀ¨ ArrayList ºÍ Vector£¬ËüÃÇÊǿɱä´óСµÄÁÐ±í£¬±È½ÏÊʺϹ¹½¨¡¢´æ´¢ºÍ²Ù×÷ÈκÎÀàÐͶÔÏóµÄÔªËØÁÐ±í¡£ List ÊÊÓÃÓÚ°´ÊýÖµË÷Òý·ÃÎÊÔªËصÄÇéÐΡ£
Map ÌṩÁËÒ»¸ö¸üͨÓõÄÔªËØ´æ´¢·½·¨¡£ Map ¼¯ºÏÀàÓÃÓÚ´æ´¢ÔªËØ ......