public String readFile(String fileName) {
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(
fileName), "UTF-16"));
StringBuilder sb = new StringBuilder();
String line = "";
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(
fileName), "UTF-16"));
StringBuilder sb = new StringBuilder();
String line = "";
while ((line = br.readLine()) !=
null) {
sb.append(line);
sb.append(System.lineSeparator());
}
sb.append(line);
sb.append(System.lineSeparator());
}
this.dataFile = sb.toString();
this.dataFile = this.dataFile.replaceAll("(\r\n|\r|\n)$", ""); // xoa cac dong trang cuoi cung
} catch (IOException e) {
e.printStackTrace();
} finally {
if (br != null)
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return this;
}
this.dataFile = this.dataFile.replaceAll("(\r\n|\r|\n)$", ""); // xoa cac dong trang cuoi cung
} catch (IOException e) {
e.printStackTrace();
} finally {
if (br != null)
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return this;
}
No comments:
Post a Comment