码迷,mamicode.com
首页 > 编程语言 > 详细

常用ファイルの操作、検索。excelの操作  java

时间:2015-09-29 16:45:54      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:

削除: del D:\ms\workspace\K1F_BATCH\src\com\mitsubishi_shokuhin\k1f\batch\JFKC011201.java コピー: echo F|xcopy D:\ms\workspace\K1F_BATCH\src\com\mitsubishi_shokuhin\k1f\batch\JFKC011201.java D:\ースXXX\K1F_BATCH\src\com\mitsubishi_shokuhin\k1f\batch\JFKC011201.java /y /r /i /f 対比: =IF(D3<>"",VLOOKUP(D3,B:C,2,0),"")

常用ソース: import java.io.File; import java.text.ParseException; import java.util.ArrayList; import java.lang.NullPointerException;

public class testLYZLYZ {

 private static ArrayList<String> filelist = new ArrayList<String>();

 private static String filePathFrom = "D://xxxxXXX";

 private static String fileTo = "D://ms//workspace-20150909LYZ";

 private static String fileToxxx = "D:\\ms\\workspace-20150909LYZ";

 private static String filePathFromxxx = "D:\\ms\\workspace-20150909";

 /**   * @param args   * @throws ParseException   */  public static void main(String[] args) throws ParseException {

  //System.out.println(subStringLenth("1234567", 0));   //return;

  getFiles(filePathFrom);  }

 private static String subStringLenth(String str, int intEnd) {   String result = "";   if (str == null || str.trim().isEmpty()) {    return result;   }   if (str.length() >= intEnd) {    return str.substring(0, intEnd);   }   return str;  }

 static void getFiles(String filePath) {   File root = new File(filePath);   File[] files = root.listFiles();   for (File file : files) {    if (file.isDirectory()) {

    getFiles(file.getAbsolutePath());     filelist.add(file.getAbsolutePath());     //    System.out.println("表示" + filePath + "サブフォルダとファイル" + file.getAbsolutePath());    }    else {     String fileName = file.getName();     String 拡張子 = checkFile(fileName);     if (!拡張子.isEmpty()) {      System.out.println(fileName + "\t" + file.getAbsolutePath() + "\t" + 拡張子);      // copy命令の作成      //     copyPrint(filePath, file.getAbsolutePath());     }    }   }  }

 private static void copyPrint(String pathTitle, String pathFromAll) {   String copy = "echo F|xcopy ";   String parCopy = " /y /r /i /f";

  String copyToAll = pathFromAll.replace(filePathFromxxx, fileToxxx);

  System.out.println(copy + pathFromAll + " " + copyToAll + " " + parCopy);  }

 private static String checkFile(String fileName) {

  if (fileName.endsWith(".java")) {    return "java";   }   if (fileName.endsWith(".js")) {    return "js";   }   if (fileName.endsWith(".jsp")) {    return "jsp";   }   if (fileName.endsWith(".css")) {    return "css";   }   if (fileName.endsWith(".xml")) {    return "xml";   }   if (fileName.endsWith(".clg2")) {    return "clg2";   }   if (fileName.endsWith(".ifd")) {    return "ifd";   }   if (fileName.endsWith(".properties")) {    return "properties";   }   if (fileName.endsWith(".dicon")) {    return "dicon";   }   if (fileName.endsWith(".scd")) {    return "scd";   }   if (fileName.endsWith(".scp")) {    return "scp";   }   if (fileName.endsWith(".classpath")) {    return "classpath";   }

  return "";  }

}

 

常用ファイルの操作、検索。excelの操作  java

标签:

原文地址:http://www.cnblogs.com/liuyunpiaohe/p/4846513.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!