Java NIO – Non Blocking IO and Multiplexing

Introduction Traditional IO is blocking in nature. For example traditional socket connection is blocking, wherein the server waits for a client connection and once the client connection is obtained an independent thread handles the operation of the client. Java NIO introduces non blocking IO wherein a thread does not have to wait for read or … Read more

Java NIO – File Locking

Introduction to File Locking File Locking is a mechanism by which access to a file by multiple processes can be controlled. File Locks may be mandatory or advisory. When an operating system implements advisory locking, if provides information about locks on a particular file to any process that asks for it, however it does not … Read more

Java IO – File Listing and directory walking

The following use cases are covered in this tutorial. Listing all files in a directory Listing files of a specific type in a directory Listing files with name matching a string Walking a directory tree with handlers for each file or directory walked Introduction Java NIO introduced the walk file tree method that is extremely … Read more

Java IO – File Copying, Moving and Deleting

File and directory Copying Copying using java.io.File To copy a file, read the data from the file using an inputstream and write to another file using an outputstream. But there are better methods for copying, so we will not spend any time on this. However, if you are interested in using this method then read … Read more

Java IO File and Path Operations

Introduction A file or a directory in the file system is represented by two abstract concepts in java. These abstract concepts are java.io.File and java.nio.file.Path. The File class represents a file in the file system whereas the interface Path represents the path string of the file. In this tutorial we look at various operations on … Read more

Java IO Introduction

Introduction Data transfer takes up a significant amount of cpu as well as developer time. If your application reads or writes data, then that is the first place that you should be looking at for performance improvements. Java IO has been around for a long time and has classes that handle most of the tasks … Read more