zoukankan      html  css  js  c++  java
  • java文件移动

    1. /** 
    2.  * 移动文件到指定的目录 
    3.  *  
    4.  * 将文件从test文件夹移动到test2文件夹
    5.  *  
    6.  */  
    7. public class MoveFile {  
    8.   
    9.     public static void main(String[] args) {  
    10.         try {  
    11.             File afile = new File("C:\test\test.txt");  
    12.             if (afile.renameTo(new File("C:\test2\" + afile.getName()))) {  
    13.                 System.out.println("File is moved successful!");  
    14.             } else {  
    15.                 System.out.println("File is failed to move!");  
    16.             }  
    17.         } catch (Exception e) {  
    18.             e.printStackTrace();  
    19.         }  
    20.     }  
    21. }
  • 相关阅读:
    资源与锁
    资源与锁
    Leetcode-Rotate List
    Leetcode-Unique Paths II
    Leetcode-Unique Paths
    Leetcode-Minimum Path Sum
    Leetcode-Sqrt(x)
    Leetcode-Set Matrix Zeroes
    Leetcode-Search a 2D Matrix
    Leetcode-Combinations
  • 原文地址:https://www.cnblogs.com/Darkqueen/p/8966048.html
Copyright © 2011-2022 走看看