public String readsqlFile() throws Exception {
String AlartTxt="";
String encoding="utf-8";
File file=new File("");
if(file.isFile() && file.exists()){ //判断文件是否存在
InputStreamReader read = new InputStreamReader(
new FileInputStream(file),encoding);//考虑到编码格式
BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt = "";
while((lineTxt = bufferedReader.readLine()) != null){
lineTxt+='\n';
AlartTxt+=lineTxt;
}
}else{
System.out.println("找不到指定的文件");
}
return AlartTxt;
}
Java读取文件,内容有换行(txt,.sql文件均可)
最新推荐文章于 2024-07-13 03:09:43 发布