下面是工具类,提供了一些文件读写及查找的功能
public class DuplicateUtils {
/**
* 根据给出的数据,往给定的文件形参中追加一行或者几行数据
*
* @param file
* @throws IOException
*/
public static Path appendFile(String splitFilename, Iterable< extends CharSequence> accessTimes,Charset cs) throws IOException {
if(accessTimes != null){
Path target = Paths.get(splitFilename);
if(target == null){
createFile(splitFilename);
}
return Files.write(target, accessTimes, cs);//, options)
}
return null;
}
/**
* 创建文件
* @throws IOException
*/
public static void createFile(String splitFilename) throws IOException {
Path target = Paths.get(splitFilename);
Set perms = PosixFilePermissions.fromString("rw-rw-rw-");