How can I read all files in a folder from Java?

Use: public void listFilesForFolder(final File folder) { for (final File fileEntry : folder.listFiles()) { if (fileEntry.isDirectory()) { listFilesForFolder(fileEntry); } else { System.out.println(fileEntry.getName()); } } } final File folder = new File(“/home/you/Desktop”); listFilesForFolder(folder); The Files.walk API is available from Java 8. try (Stream<Path> paths = Files.walk(Paths.get(“/home/you/Desktop”))) { paths .filter(Files::isRegularFile) .forEach(System.out::println); } The example uses the try-with-resources … Read more

How to have git-svn take care of empty directories gracefully?

Use rmdir argument or config parameter: –rmdir Only used with the dcommit, set-tree and commit-diff commands. Remove directories from the SVN tree if there are no files left behind. SVN can version empty directories, and they are not removed by default if there are no files left in them. git cannot version empty directories. Enabling … Read more

list all files from directories and subdirectories in Java

As this answer shows up on top of google, i’m adding a java 7 nio solution for listing all files and directories, it is takes about 80% less time on my system. try { Path startPath = Paths.get(“c:/”); Files.walkFileTree(startPath, new SimpleFileVisitor<Path>() { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { System.out.println(“Dir: ” + dir.toString()); return … Read more

Copy folders without files, files without folders, or everything using PowerShell

To copy everything in a folder hierarchie Copy-Item $source $dest -Recurse -Force To copy the hierarchie you can try: $source = “C:\ProdData” $dest = “C:\TestData” Copy-Item $source $dest -Filter {PSIsContainer} -Recurse -Force To flatten a file structure you can try: $source = “C:\ProdData” $dest = “C:\TestData” New-Item $dest -type directory Get-ChildItem $source -Recurse | ` … Read more

Multiple directories and/or subdirectories in IPython Notebook session?

The IPython documentation pages suggest that opening several different sessions of IPython notebook is the only way to interact with saved notebooks in different directories or subdirectories, but this is not explicitly confirmed anywhere. Yes, this is a current (temporary) limitation of the Notebook server. Multi-directory support is very high on the notebook todo list … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)