標籤:java io str int tst false trace io流 imp nts
http://www.verejava.com/?id=17160016947046
public class Test2 { public static void main(String[] args) { FileUtil.createFile("test2.txt"); FileUtil.renameFile("test2.txt", "newTest2.txt"); FileUtil.deleteFile("newTest2.txt"); }}//檔案工具封裝import java.io.File;import java.io.IOException;import java.util.logging.Level;import java.util.logging.Logger;public class FileUtil { //檔案的建立 public static boolean createFile(String filePath) { File f=new File(filePath); try { return f.createNewFile(); } catch (IOException ex) { ex.printStackTrace(); } return false; } //檔案的重新命名 public static boolean renameFile(String oldPath,String newPath) { File oldFile=new File(oldPath); return oldFile.renameTo(new File(newPath)); } //檔案的刪除 public static boolean deleteFile(String filePath) { File f=new File(filePath); //判斷是否是檔案 並且存在 if(f.isFile()&&f.exists()) { return f.delete(); } return false; }}
http://www.verejava.com/?id=17160016947046
Java IO流 之 File 工具封裝 FileUtil