File Locking can be achieved in java by making use of the New I/O API (nio). Before the advent of New I/O API, there was no direct support in Java for locking a file. It is important to understand that File locking is hugely dependent on the native operating system on which the program is …
File IO
File Upload and Download using Java
File Upload and Download is always a handy utility to know. There will be some need to upload a file to an FTP server, Like if you generate a report or store some data in .xls file, then it needs to be uploaded to a FTP server for further use. like wise we need to …
Copying File Contents using FileChannel
In this technical tip, let us see an easy way of achieving file copy using File Channels. File Channels are part of Java New I/O Packages. A file can be viewed as a sequence of bytes. The various Buffer classes in New I/O Packages serve as a container for manipulating the primitive byte contents. It …
Randomly accessing the file contents
In this techincal tip, let us see how to access the contents of a file randomly instead of the traditional sequential access. Imagine that we want to search for a particular record in a file. If we prefer Sequential access in this case, then it will involve traversing over the file byte by byte and …
Recursively traversing files and folders using Java File API
In this section, let us see how to recursively traverse over files and folders by making use of Java File API. Whether it is a folder or a file, both are represented as a java.io.File object. For example, consider the following code snippet, also read: Java Tutorials Java EE Tutorials Design Patterns Tutorials Java File …