日期:2014-05-20 浏览次数:20808 次
package com.jctest.one;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class ReadText {
public String ReadDate() {
String url = "c:/test.txt";
String strs = "";
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());
String a = sb.toString().replaceAll("@@@@@", ",");
strs = a.substring(0,a.length()-1);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return strs ;
}
public static void main(String a[])
{
ReadText util = new ReadText();
String cc = util.ReadDate();
System.out.println("result...."+cc);
}
}