public class Utils {
public static void main(String arg[]) {
try {
String encoding = "GBK"; // 字符编码(可解决中文乱码问题 )
File file = new File("c:/accounts.txt");
if (file.isFile() && file.exists()) {
InputStreamReader read = new InputStreamReader(
new FileInputStream(file), encoding);
BufferedReader bufferedReader = new BufferedReader(read);
String lineTXT = null;
String [][] array = null;
int count = 0;
while ((lineTXT = bufferedReader.readLine()) != null) {
String text = "";
//用字符分隔成数组
String str1 = lineTXT.replaceAll("\t","@");
String[] str2 = str1.split("@");
System.out.println("-----------");
System.out.println(str2[0]+","+str2[1]+","+str2[2]+"");
}
read.close();
}else{
System.out.println("找不到指定的文件!");
}
} catch (Exception e) {
System.out.println("读取文件内容操作出错");
}
}
}
93

被折叠的 条评论
为什么被折叠?



