SHARE
TWEET

Untitled

a guest Oct 18th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public void rm(String sourcePath) {
  2.         File f= new File (sourcePath);
  3.         File f1= new File (Dd+sourcePath);
  4.         if (f1.exists()) {
  5.             if(f.delete())
  6.                 System.out.println("deleted");
  7.             else
  8.                 System.out.println("Not deleted");
  9.         }
  10.         else if (f.exists()) {
  11.             if(f.delete())
  12.                 System.out.println("deleted");
  13.             else
  14.                 System.out.println("Not deleted");
  15.         }
  16.    
  17.     }
  18.    
  19. public Boolean cp(String sourcePath, String destinationPath ) {
  20.        
  21.         String a="";
  22.         File f =new File(sourcePath);
  23.         File f1= new File (Dd+sourcePath);
  24.         if (f1.exists()) {
  25.             a=Dd+sourcePath;
  26.            
  27.         }
  28.          
  29.         else if (f.exists()) {
  30.             a=sourcePath;
  31.  
  32.         }
  33.         else {
  34.             System.out.println("can't find source to copy");
  35.             return false;
  36.         }
  37.        
  38.         try {
  39.        
  40.         FileReader myReader= new FileReader(a);
  41.         File file1= new File(destinationPath);
  42.         File file2= new File(Dd+destinationPath);
  43.         String b;
  44.         if (file2.createNewFile()||file2.exists()) {
  45.             b=Dd+destinationPath;
  46.         }
  47.         else if (file1.createNewFile()||file1.exists()) {
  48.             b=destinationPath;
  49.         }
  50.         else {
  51.             System.out.println("wrong destination path");
  52.             return false;
  53.            
  54.         }
  55.         FileWriter myWriter= new FileWriter(b);
  56.        
  57.         Scanner read= new Scanner(myReader);
  58.         String s;
  59.         while (read.hasNextLine()) {
  60.              s = read.nextLine();
  61.              myWriter.write(s+"\n");
  62.         }
  63.  
  64.         myReader.close();
  65.         myWriter.close();
  66.         read.close();
  67.         return true;
  68.         }
  69.         catch(IOException e) {
  70.             System.out.println("wrong input");
  71.             return false;}
  72.     }
  73.  
  74.     public void mv(String sourcePath, String destinationPath )throws IOException{
  75.     if(cp( sourcePath,  destinationPath ))
  76.         rm(sourcePath);
  77.    
  78.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top