Skip to content
Advertisement

Tag: directory

Search for all po files in a directory and its subdirectories and create a Hashmap containing the filepaths as value and its directory as key

I want to search for all .po files in a directory and add them to a HashMap. My directories looks like the following: How can I represent/search these files with the help of java-Streams and HashMap<String, List<File>>, with en/de/it.po as a List<File> type and the respective directory root of these files dir1subdir-1**subdir-n as a key? I’ve tried the following solution

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: My pom.xml dependencies The code:

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 folder (2014) already exists. What I actually want to do

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.zip will be present inside reports. (That means

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.

Advertisement