public void show() {
String filePathDB = "";
filePathDB = "infAll\\" + name.replace("infAll", "") + ".txt";
try {
String encoding = "GBK";
File file = new File(filePathDB);
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("打开" + name + "文件");
System.out.println(lineTxt);
sss.showxiangxi.setText(lineTxt);
}
read.close();
} else {
System.out.println("找不到指定的文件");
sss.showxiangxi.setText("null");
}
} catch (Exception e) {
System.out.println("读取文件内容出错");
sss.showxiangxi.setText("null");
e.printStackTrace();
}
}
String filePathDB = "";
filePathDB = "infAll\\" + name.replace("infAll", "") + ".txt";
try {
String encoding = "GBK";
File file = new File(filePathDB);
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("打开" + name + "文件");
System.out.println(lineTxt);
sss.showxiangxi.setText(lineTxt);
}
read.close();
} else {
System.out.println("找不到指定的文件");
sss.showxiangxi.setText("null");
}
} catch (Exception e) {
System.out.println("读取文件内容出错");
sss.showxiangxi.setText("null");
e.printStackTrace();
}
}