Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.IOException;
- import java.nio.file.FileSystems;
- import java.nio.file.Files;
- import java.nio.file.Path;
- import java.util.Scanner;
- public class UnhideFiles {
- public static void main(String[] args) throws IOException {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Paste the directory in here");
- File file = new File(scanner.nextLine());
- makeFilesUnhidden(file);
- }
- static void makeFilesUnhidden(File file) {
- if (file.isHidden()) {
- unhide(file);
- }
- if (file.isDirectory()) {
- for (File f : file.listFiles()) {
- makeFilesUnhidden(f);
- }
- }
- }
- static void unhide(File file) {
- Path path = FileSystems.getDefault().getPath(file.getAbsolutePath());
- try {
- Files.setAttribute(path, "dos:hidden", false);
- System.out.println("unhid " + file);
- } catch (IOException e) {
- System.err.println("didn't unhide " + file);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement