Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.IOException;
  3. import java.nio.file.FileSystems;
  4. import java.nio.file.Files;
  5. import java.nio.file.Path;
  6. import java.util.Scanner;
  7.  
  8. public class UnhideFiles {
  9.  
  10. public static void main(String[] args) throws IOException {
  11. Scanner scanner = new Scanner(System.in);
  12. System.out.println("Paste the directory in here");
  13. File file = new File(scanner.nextLine());
  14. makeFilesUnhidden(file);
  15. }
  16.  
  17. static void makeFilesUnhidden(File file) {
  18. if (file.isHidden()) {
  19. unhide(file);
  20. }
  21. if (file.isDirectory()) {
  22. for (File f : file.listFiles()) {
  23. makeFilesUnhidden(f);
  24. }
  25. }
  26. }
  27.  
  28. static void unhide(File file) {
  29. Path path = FileSystems.getDefault().getPath(file.getAbsolutePath());
  30. try {
  31. Files.setAttribute(path, "dos:hidden", false);
  32. System.out.println("unhid " + file);
  33. } catch (IOException e) {
  34. System.err.println("didn't unhide " + file);
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement