Advertisement
Guest User

Untitled

a guest
Feb 1st, 2017
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1.  public String polecenieMV(String plik, String sciezka){
  2.         String wynik;
  3.         MoveFileToDirectory_CopyDelete(bkatalog+"//"+plik,bkatalog+"//"+sciezka+"//"+plik);
  4.         wynik=plik+sciezka;
  5.         return wynik;
  6.     }
  7.  
  8. public static void MoveFileToDirectory_CopyDelete(String pathFile,String pathFile2)
  9.     {
  10.         InputStream inStream = null;
  11.         OutputStream outStream = null;
  12.  
  13.         try{
  14.  
  15.             File afile =new File(pathFile);
  16.             File bfile =new File(pathFile2);
  17.  
  18.             inStream = new FileInputStream(afile);
  19.             outStream = new FileOutputStream(bfile);
  20.  
  21.             byte[] buffer = new byte[1024];
  22.  
  23.             int length;
  24.  
  25.             while ((length = inStream.read(buffer)) > 0){
  26.  
  27.                 outStream.write(buffer, 0, length);
  28.  
  29.             }
  30.  
  31.             inStream.close();
  32.             outStream.close();
  33.  
  34.             afile.delete();
  35.  
  36.             System.out.println("Plik zostal przeniesiony poprawnie!");
  37.  
  38.         }catch(IOException e){
  39.             e.printStackTrace();
  40.         }
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement