### Question:
FileUtil { public final static boolean appendLine(File file, String str) { try ( RandomAccessFile randomFile = new RandomAccessFile(file, "rw") ) { long fileLength = randomFile.length(); randomFile.seek(fileLength); randomFile.writeBytes(SysUtil.FILE_SEPARATOR + str); return true; } catch (IOException e) { e.printStackTrace(); } return false; }  static String fileMD5(File file); final static int countLines(File file); final static List<String> lines(File file); final static List<String> lines(File file, String encoding); final static List<String> lines(File file, int lines); final static List<String> lines(File file, int lines, String encoding); final static boolean appendLine(File file, String str); final static boolean appendLine(File file, String str, String encoding); final static boolean write(File file, String str); final static boolean writeAppend(File file, String str); final static boolean write(File file, String str, String encoding); final static boolean writeAppend(File file, String str, String encoding); final static boolean cleanFile(File file); final static String mimeType(String file); final static String fileType(File file); final static Date modifyTime(File file); final static boolean copy(String resourcePath, String targetPath); final static boolean copy(File file, String targetFile); final static boolean createPaths(String paths); final static boolean createFiles(String filePath); final static boolean deleteFile(File file); final static boolean deleteDir(File file); final static boolean deleteBigFile(File file); final static void copyDir(String filePath, String targetPath); final static void copyDir(File filePath, String targetPath); final static List<File> listFile(String path); final static List<File> listFile(String path, boolean child); final static List<File> listFile(File path); final static List<File> listFile(File path, boolean child); final static List<File> listFileAll(File path); final static List<File> listFileFilter(File path, FilenameFilter filter); final static List<File> listFileFilter(File dirPath, final String postfixs); final static List<File> searchFile(File dirPath, String fileName); final static List<File> searchFileReg(File dirPath, String reg); final static String suffix(File file); static MessageDigest MD5; }### Answer:
@Test public void testAppendLine() { System.out.println("向文件中追加行"); String line1 = "E-String"; String line2 = "中文字符串"; File efile = new File(path + "/text/EnglishWrite.txt"); File gbkfile = new File(path + "/text/GBKWrite.txt"); File utf8file = new File(path + "/text/UTF8Write.txt"); FileUtil.appendLine(efile, line1); FileUtil.appendLine(efile, line2); FileUtil.appendLine(efile, line1, Opslab.UTF_8); FileUtil.appendLine(efile, line2, Opslab.UTF_8); FileUtil.appendLine(gbkfile, line1); FileUtil.appendLine(gbkfile, line2); FileUtil.appendLine(gbkfile, line1, "GBK"); FileUtil.appendLine(gbkfile, line2, "GBK"); FileUtil.appendLine(utf8file, line1); FileUtil.appendLine(utf8file, line2); FileUtil.appendLine(utf8file, line1, Opslab.UTF_8); FileUtil.appendLine(utf8file, line2, Opslab.UTF_8); }