Java¶ÁдtxtÎļþ
±ÊÊÔµÄʱºòÏë²»ÆðÀ´ÔõôдÁË¡£Áô¸ö´úÂë×÷¼ÍÄî
package common;
import java.io.*;
import java.util.ArrayList;
public class IOTest {
public static void main (String args[]) {
ReadDate();
WriteDate();
}
/**
* ¶ÁÈ¡Êý¾Ý
*/
public static void ReadDate() {
String url = "e:/2.txt";
try {
FileReader read = new FileReader(new File(url));
StringBuffer sb = new StringBuffer();
char ch[] = new char[1024];
int d = read.read(ch);
while(d!=-1){
String str = new String(ch,0,d);
sb.append(str);
d = read.read(ch);
}
System.out.print(sb.toString());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* дÈëÊý¾Ý
*/
public static void WriteDate() {
try{
File file = new File("D:/abc.txt");
if (file.exists()) {
file.delete();
}
file.createNewFile();
BufferedWriter output = new BufferedWriter(new FileWriter(file));
ArrayList ResolveList = new ArrayList();
for (int i = 0; i < 10; i++) {
ResolveList.add(Math.random()* 100);
}
for (int i=0 ;i<ResolveList.size(); i++) {
output.write(String.valueOf(ResolveList.get(i)) + "\n");
}
output.close();
} catch (Exception ex) {
System.out.println(ex);
}
}
}
Ïà¹ØÎĵµ£º
Îļþ´ò¿ªÊ±ºòÊÇͨ¹ýÎļþÍ·À´È·¶¨ÎļþµÄ±àÂë
StreamReader sr=new StreamReader(@"F:\cym\temp\1.txt");
sr.CurrentEncoding //·µ»Ø±àÂë
ÊÀ½çÉϵĸ÷µØÇø¶¼Óб¾µØµÄÓïÑÔ¡£µØÇø²îÒìÖ±½Óµ¼ÖÂÁËÓïÑÔ»·¾³µÄ²îÒì¡£ÔÚ¿ª·¢Ò»¸ö¹ú¼Ê»¯³ÌÐòµÄ¹ý³ÌÖУ¬´¦ÀíÓïÑÔÎ ......
package chape8;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* µÚ°ËÕ ͨÓóÌÐòÉè¼Æ
* µÚ45Ìõ£º ½«¾Ö²¿±äÁ¿µÄ×÷ÓÃÓò¼õСµ½×îС
* ½«¾Ö²¿±äÁ¿µÄ×÷ÓÃÓò×îС»¯¡£¿ÉÒÔÔöÇ¿´úÂëµÄ¿É¶ÁºÍ¿Éά»¤ÐÔ£¬²¢½µµÍ³ö´íµÄ¿ÉÄÜÐÔ
* Ҫʹ×÷ÓÃÓò×îС£¬×îÓÐÁ ......
Character Classes
[abc] Simple character class
[a-zA-Z]   ......
java exception ½â¾ö·½°¸ - ÎÒµÄÒì³£Íø|Òì³£|exception 791 - java.lang.NoSuchMethodError 792 - RuntimeException 793 - org.hibernate.exception.SQLGrammarException 794 - Internal Error 795 - ×Ô¶¨ÒåÒì³£ 796 - org.dom4j.DocumentException 797 - java.net.SocketException 798 - Exception¶ÔÏó 799 - SQLE ......