Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. public void moveWritableTxtFiles(String from, String to) throws IOException {
  2.  
  3. File f = new File(from);
  4. File t = new File(to);
  5.  
  6. if(!t.exists())
  7. {
  8. t.mkdir();
  9. }
  10. if(f.exists()){
  11. File files[] = f.listFiles();
  12.  
  13. for (File file : files) {
  14.  
  15. if(file.getName().endsWith(".txt"))
  16. {
  17.  
  18. if(file.canWrite() && t.canWrite())
  19. {
  20. System.out.println(file.getName());
  21. System.out.println(file.renameTo(new File(t.getPath().toString()+"\\"+file.getName())));
  22. }
  23. }
  24. }
  25. }
  26. else {
  27. System.out.println("Ne postoi");
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement