改成这样package sql;
import java.io.*;public class ReadFile {
// Create file
private String currentRecord = null;//保存文本的变量
private BufferedReader file; //BufferedReader对象,用于读取文件数据
private String path;//文件完整路径名
private String a="";//信息的集合
public ReadFile() {
}
public String ReadFile0(String filePath) throws IOException
{
path = filePath;
//创建新的BufferedReader对象
file = new BufferedReader(new FileReader(path));
String s="";
try {
// Create a buffered reader to read each line from a file.
// Read each line from the file and echo it to the screen.
while ((s = file.readLine()) != null) {
a+=s+"/";
//System.out.println(s);
}
// Close the buffered reader, which also closes the file reader.
currentRecord=a;
file.close();
} catch (IOException e1) {
// If this file does not exist
System.out.println("写入文件错误"+e1.getMessage()); }
return currentRecord;
}
}
import java.io.*;public class ReadFile {
// Create file
private String currentRecord = null;//保存文本的变量
private BufferedReader file; //BufferedReader对象,用于读取文件数据
private String path;//文件完整路径名
private String a="";//信息的集合
public ReadFile() {
}
public String ReadFile0(String filePath) throws IOException
{
path = filePath;
//创建新的BufferedReader对象
file = new BufferedReader(new FileReader(path));
String s="";
try {
// Create a buffered reader to read each line from a file.
// Read each line from the file and echo it to the screen.
while ((s = file.readLine()) != null) {
a+=s+"/";
//System.out.println(s);
}
// Close the buffered reader, which also closes the file reader.
currentRecord=a;
file.close();
} catch (IOException e1) {
// If this file does not exist
System.out.println("写入文件错误"+e1.getMessage()); }
return currentRecord;
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货