Created
May 9, 2018 15:55
-
-
Save penut85420/2e843062695ac229b4fa723bb4f6ceba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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