package File;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
public class Utils {
public static void main(String arg[]) {
try {
String encoding = “GBK”; // 字符编码(可解决中文乱码问题 )
File file = new File(“F:/aaa.txt”);
if (file.isFile() && file.exists()) {
InputStreamReader read = new InputStreamReader(
new FileInputStream(file), encoding);
BufferedReader bufferedReader = new BufferedReader(read);
String lineTXT = null;
while ((lineTXT = bufferedReader.readLine()) != null) {
//System.out.println(lineTXT );
//将文本读取出来的字符去掉”,” 因为读取出来的字符是用”,”来分隔的
String text = lineTXT.replaceAll(“,”, “”);
//用字符分隔成数组
String[] version_1 = text.split(“-“);
for (int i = 0; i < version_1.length; i++) {
String[] version_2 = version_1[i].split(“:”);
for (int j = 0; j < version_2.length; j++) {
System.out.println(version_2[j]);
}
System.out.println(“——-“);
}
}
read.close();
}else{
System.out.println(“找不到指定的文件!”);
}
} catch (Exception e) {
System.out.println(“读取文件内容操作出错”);
e.printStackTrace();
}
}
}