¶ÁÎļþ£¨java£©
ʹÓÃJava²Ù×÷Îı¾ÎļþµÄ·½·¨Ïê½â
ÕªÒª: ×î³õjavaÊDz»Ö§³Ö¶ÔÎı¾ÎļþµÄ´¦ÀíµÄ£¬ÎªÁËÃÖ²¹Õâ¸öȱº¶¶øÒýÈëÁËReaderºÍWriterÁ½¸öÀ࣬ÕâÁ½¸öÀ඼ÊdzéÏóÀ࣬WriterÖÐ write(char[] ch,int off,int
length)£¬flush()ºÍclose()·½·¨Îª³éÏó·½·¨£¬ReaderÖÐread(char[] ch,int off,int length)ºÍclose()·½·¨ÊdzéÏó·½·¨¡£×ÓÀàÓ¦¸Ã·Ö±ðʵÏÖËûÃÇ¡£ µ±ÎÒÃǶÁдÎı¾ÎļþµÄʱºò£¬²ÉÓÃReaderÊǷdz£·½±ãµÄ£¬±ÈÈçFileReader£¬InputStreamReaderºÍBufferedReader¡£ÆäÖÐ×îÖØÒªµÄÀàÊÇInputStreamReader£¬ËüÊÇ×Ö½Úת»»Îª×Ö·ûµÄÇÅÁº¡£Äã¿ÉÒÔÔÚ¹¹ÔìÆ÷ÖØÖ¸¶¨±àÂëµÄ·½Ê½£¬Èç¹û²»Ö¸¶¨µÄ»°½«²ÉÓõײã²Ù×÷ϵͳµÄĬÈϱàÂ뷽ʽ£¬ÀýÈçGBKµÈ¡£µ±Ê¹ÓÃFileReader¶ÁÈ¡ÎļþµÄʱºò¡£FileReader fr = new FileReader("ming.txt");
int ch = 0;
while((ch = fr.read())!=-1 )
{
System.out.print((char)ch);
}
ÆäÖÐread()·½·¨·µ»ØµÄÊǶÁÈ¡µÃϸö×Ö·û¡£µ±È»ÄãÒ²¿ÉÒÔʹÓÃread(char[] ch,int off,int length)ÕâºÍ´¦Àí¶þ½øÖÆÎļþµÄʱºòÀàËÆ£¬²»¶à˵ÁË¡£Èç¹ûʹÓÃInputStreamReaderÀ´¶ÁÈ¡ÎļþµÄʱºòwhile((ch = isr.read())!=-1)
{
System.out.print((char)ch);
}
ÕâºÍFileReader²¢Ã»ÓÐʲôÇø±ð£¬ÊÂʵÉÏÔÚFileReaderÖеķ½·¨¶¼ÊÇ´ÓInputStreamReaderÖм̳йýÀ´µÄ¡£read()·½·¨ÊDZȽϺ÷Ñʱ¼äµÄ£¬Èç¹ûΪÁËÌá¸ßЧÂÊÎÒÃÇ¿ÉÒÔʹÓÃBufferedReader¶ÔReader½øÐаü×°£¬ÕâÑù¿ÉÒÔÌá¸ß¶ÁÈ¡µÃËٶȣ¬ÎÒÃÇ¿ÉÒÔÒ»ÐÐÒ»ÐеĶÁÈ¡Îı¾£¬Ê¹ÓÃreadLine()·½·¨¡£BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("ming.txt")));
String data = null;
while((data = br.readLine())!=null)
{
System.out.println(data);
}
µ±ÄãÃ÷°×ÁËÈçºÎÓÃReaderÀ´¶ÁÈ¡Îı¾ÎļþµÄʱºòÄÇôÓÃWriterдÎļþͬÑù·Ç³£¼òµ¥¡£ÓÐÒ»µãÐèҪעÒ⣬µ±ÄãдÎļþµÄʱºò£¬ÎªÁËÌá¸ßЧÂÊ£¬Ð´ÈëµÄÊý¾Ý»áÏÈ·ÅÈ뻺³åÇø£¬È»ºóдÈëÎļþ¡£Òò´ËÓÐʱºòÄãÐèÒªÖ÷¶¯µ÷ÓÃflush()·½·¨¡£ÓëÉÏÃæ¶ÔÓ¦µÄдÎļþµÄ·½·¨Îª£º
FileWriter fw = new FileWriter("hello.txt");
String s = "hello world";
fw.write(s,0,s.length());
fw.flush();OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("hello2.txt"));
osw.write(s,0,s.length());
osw.flush();PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream("hello3.txt")),true);
pw.println(s);
²»ÒªÍü¼ÇÓÃÍêºó¹Ø±ÕÁ
Ïà¹ØÎĵµ£º
Debug͸ÊÓͼ
http://www.cnblogs.com/Jamesliang/archive/2010/01/09/1643188.html
µ±µã»÷Debug°´Å¥Ê±£¬Eclipse»áÌáʾÄã½øÈë Debug͸ÊÓͼ¡£¿ÉÒÔÔÚÓÒÉÏ·½Expressions´°¿Úµã»÷Êó±êÓÒ¼üÔÚµ¯³ö²Ëµ¥ÖÐÑ¡Ôñ Add Watch Expression »òÕßµã»÷ÈçÏÂͼËùʾ°´Å¥Ôò»á³öÏÖ£¬Ìí¼Ó±í´ïʽ´°¿Ú¡£Äã¿ÉÒÔÊäÈëÄã ......
JAVA CLASSPATH ºÍPATHµÄÇø±ð ÊÕ²Ø
PATH:¡¡ÓÃÀ´Ö¸¶¨ java ÐéÄâ»ú(JVM) ËùÔÚÔÚĿ¼,Ò²¾ÍÊÇÎÒÃÇ×î³£ÓõÄÓÃÀ´±àÒëjavaÔ´³ÌÐòµÄjavac.exe ºÍÓÃÀ´Ö´ÐÐ *.class ÎļþµÄ java.exe ÕâÁ½¸öÃüÁî¡£ÒÔÎҵĻúÆ÷ΪÀý°É£ºÎÒµÄ jdk °´×°Ä¿Â¼Îª D:\jdk1.5.0_08£¨È·ÇеÄ˵ÎÒµÄÕâ¸öJDK²»ÊÇ°²×°°æ±¾µÄ£¬Ö±½Ó½âѹµ½ d:\ Ï嵀 £¬´ËʱÎÒµÄ path ¾ ......
Integer n1 = new Integer(1);
Integer n2 = new Integer(1);
System.out.println(n1==n2); // false
Integer n1 = new Integer(3);
Integer n2 = new Integer(3);
System.out.println(n1.equals(n2)); //true
equals()ĬÈÏÒ²ÊDZȽÏreference£¬µ«ÊÇJavaÖеÄclass¸²¸ÇÁËequals()·½·¨ ......
1. Ñ»·listÖеÄËùÓÐÔªËØÈ»ºóɾ³ýÖظ´
public static List removeDuplicate(List list) {
for ( int i = 0 ; i < list.size() - 1 ; i ++ ) {
for ( int j = list.size() - 1 ; j > i; j -- ) {
if (list.get(j).equals(list.get(i))) {
......