Skip to content

Instantly share code, notes, and snippets.

@penut85420
Created May 9, 2018 15:55
Show Gist options
  • Save penut85420/2e843062695ac229b4fa723bb4f6ceba to your computer and use it in GitHub Desktop.
Save penut85420/2e843062695ac229b4fa723bb4f6ceba to your computer and use it in GitHub Desktop.
public static String file_read(String file) {
String sFile = null;
try {
FileInputStream fin = new FileInputStream(file);
byte ba[] = new byte[fin.available()];
fin.read(ba);
// 將文字用UTF-8解碼
sFile = new String(ba, "UTF-8");
// 將BOM檔頭去掉
sFile = sFile.replace("\uFEFF", "");
fin.close();
} catch (IOException e) { e.printStackTrace(); }
return sFile;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment