Skip to content

Tag: directory

Hadoop 2.6.0 Browsing filesystem Java

I have installed a basic hadoop cluster on CentOS 6.6 and want to write a few basic programs (browse the filesystem, delete/add files, etc) but I’m struggling to get even the most basic app working. When running some basic code to list the contents of a directory to the console I get the following error…

Moving files from one directory to another with Java NIO

I am using the NIO libraries but I am getting a strange error when I try to move files from one directory to another. Iterate over elements that start with “2014” and move them in the new directory (newDir, which is also called 2014) I get the java.nio.file.FileAlreadyExistsException because my fo…

Load a file from src folder into a reader

I would like to know how can I load a file lol.txt from src folder into my close method. The code so far: Console error output on initiation: Answer If you like to load the file from inside a jar file (i.e. from classpath) please see this answer for more options on how to get an InputStream. In the code

how to zip a folder itself using java

Suppose I have the following directory structure. Inside january there are suppose two excel files say A.xls and B.xls. There are many places where it has been written about how to zip files using java.util.zip. But I want to zip the january folder itself inside reports folder so that both january and january…

How to create a directory in Java?

How do I create Directory/folder? Once I have tested System.getProperty(“user.home”); I have to create a directory (directory name “new folder” ) if and only if new folder does not exist. Answer After ~7 year, I will update it to better approach which is suggested by Bozho.