1. 程式人生 > 實用技巧 >獲取本地磁碟得到.txt檔案

獲取本地磁碟得到.txt檔案

public void getTXT() {
        String str ="C:\";
        log.info("獲取TxT:" + str);
        refreshFileList(str);
    }
    

private void refreshFileList(String str) {
        log.info("進入方法"+str);
        File dir = new File(str);
        log.info("進入方法1"+dir);
        File[] files = dir.listFiles();
        log.info(
"進入方法2"+files); if (files == null) return; for (File file : files) { if (file.isDirectory()) { refreshFileList(file.getAbsolutePath()); } else { if (file.getName().endsWith(".TXT")) { log.info("========--" + file + "file.getName()" + file.getName()); String s
= file.getName().substring(0, 19);
            //檔案路徑 file.getPath(); CreateConnection(s,file.getPath()); log.info(
"====wwwwwww" + s); } } } }