File seperator sample pgm
package com.demo;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.output.FileWriterWithEncoding;
public class FileSeperator {
public static void main(String[] args) {
String path = "C:";
File f1 = new File("c:\\sampleclean");
File f2 = new File("c:\\out.txt");
File f3 = new File("c:\\test.txt");
String pathSep = path + File.separator+ "Hello" + File.separator;
System.out.println(pathSep);
try {
FileUtils.cleanDirectory(f1);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
FileUtils.contentEquals(f2, f3);
System.out.println("exeuted");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/* try {
FileUtils.contentEqualsIgnoreEOL(f2, f3, "j");
System.out.println("contents");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
try {
FileUtils.writeStringToFile(f2, "hello first pgm");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
No comments:
Post a Comment