Tag Archives: NIO

Delete directory with contents in Java

Removing empty directory in Java is as simple as calling File.delete() (standard IO) or Files.delete() (NIO) method. However, if the folder is not empty (for example contains one or more files or subdirectories), these methods will refuse to remove it. … Continue reading

Posted in Java, Maven, Uncategorized | Tagged , , , | 1 Comment

How to delete file in Java

File management (good old CRUD: create, read, update, delete) is quite common operation in software development. In this short post I would like to present 2 ways of removing files in Java. Method available in every Java version Every Java … Continue reading

Posted in Java, Uncategorized | Tagged , | Leave a comment

Reading text file line by line in Java

Reading text files from hard disk is quite common task in software development practice. Usually we are interested in processing it line by line. In this article I would like to present few popular ways how to do it easily … Continue reading

Posted in Java | Tagged , | Leave a comment

Recursively walking directory using Java NIO

Sometimes you may need to recursively visit all files and subdirectories of given directory and perform some actions on it. The typical use case is searching files of a given type, copying or removing a directory including all its contents. … Continue reading

Posted in Java | Tagged , , | 4 Comments

Create temporary files and directories using Java NIO2

Temporary files and directories are very useful in many situations. One typical case is that you are writing some (usually large) file and you don’t want anybody to accidentally access and mess with it until is completely written and closed. … Continue reading

Posted in Java | Tagged , | 1 Comment