/** * 讀檔 .txt **/ public static String readTxt(String File, String Coding) { String rtn = ""; int i = 0; try { // 判斷檔案是否存在 File file = new File(File); if (file.exists() != false && file.isFile() != false) { Path path = Paths.get(File); // 讀出文字檔 rtn = new String(Files.readAllBytes(path), Coding); } } catch (Exception e) { e.printStackTrace(); } return rtn; }