How to Use File Separator to construct file path in java?

How to Use File Separator to construct file path in java?
DeeKay June 10, 2012 at 11:52 pm · java.io

Many java developers might have came across the code where the developer need to use file separator for the file path or directory path. Many of them are using “/” or “\” depending upon the operating system. Using the forward or backward slash is not a good practice while coding in the java, because your code may…
Continue Reading »


How to Read UTF-8 data from File in Java ?

How to Read UTF-8 data from File in Java ?
DeeKay June 10, 2012 at 11:08 pm · java.io

Below Java Code shows how to read UTF-8 data from file or read UTF-8 encoded data from a text file-


How to Write UTF-8 Data into a File Using Java ?

How to Write UTF-8 Data into a File Using Java ?
DeeKay June 10, 2012 at 2:22 am · java.io

Below Java Code shows how to write UTF-8 data into a file using Java –


How to get the size of a file in java?

How to get the size of a file in java?
DeeKay April 7, 2012 at 2:42 am · java.io

Below java code shows how to get the size of a file in bytes –


How to get the list of file system root in java?

How to get the list of file system root in java?
DeeKay April 7, 2012 at 2:28 am · java.io

Below java code show how to get the list of file system root –  


How to get current working directory in java?

How to get current working directory in java?
DeeKay April 6, 2012 at 2:39 am · java.io

You can get current working directory using System.getProperty(“user.dir”) function. Here current working directory means the root folder of your current Java project. Below java code shows how to get current working directory of user –   References: Oracle Java Docs for System Properties


How to check if a file exists in java?

How to check if a file exists in java?
DeeKay March 19, 2012 at 1:12 am · java.io

Below Java code shows how to check if a file exists –


How to create directories recursively in java?

How to create directories recursively in java?
DeeKay March 8, 2012 at 1:12 am · java.io

Below java code shows how to create directories recursively –


How to change a file attribute to read only in java?

How to change a file attribute to read only in java?
DeeKay March 8, 2012 at 12:58 am · java.io

Below java code shows how to change file attribute to read only –


How to find if a pathname is a directory in java?

How to find if a pathname is a directory in java?
DeeKay March 8, 2012 at 12:24 am · java.io

Below java code shows how to find whether the specified path is directory or file –


How to display file contents into Hexadecimal format in java?

How to display file contents into Hexadecimal format in java?
DeeKay March 6, 2012 at 11:33 pm · java.io

Below java code shows how to convert and display file contents into Hexadecimal format –  


How to List Files and Sub-directories in a Directory in Java?

How to List Files and Sub-directories in a Directory in Java?
DeeKay March 6, 2012 at 12:17 am · java.io

Below java code shows how to list files and sub-directories in a directory –  


How to load a File into Byte Array in Java ?

How to load a File into Byte Array in Java ?
DeeKay March 5, 2012 at 11:57 pm · java.io

Below java code shows how to load a file into Byte Array and print the Byte Array –  


How to write Exception’s PrintStackTrace to a File in Java?

How to write Exception’s PrintStackTrace to a File in Java?
DeeKay March 5, 2012 at 7:00 pm · java.io

Usually when you generate an exception in a Java program, you just print the exception to standard output using below code statement System.out.println(“Got an Exception: ” + e.getMessage()); But this is not what you want. Sometime you want to write Exception’s PrintStackTrace to a file and below Java program shows you how to write Exception’s…
Continue Reading »


How to remove line from file in java?

How to remove line from file in java?
DeeKay October 3, 2011 at 11:27 pm · java.io

Below java code shows how to remove line from file


How to rename file in java? How to change file name in java?

How to rename file in java? How to change file name in java?
DeeKay October 3, 2011 at 11:06 pm · java.io

Below java code shows how to rename a file or change a file name


How to read data from InputStream to a String in Java?

How to read data from InputStream to a String in Java?
DeeKay September 30, 2011 at 1:27 am · java.io

Below java code shows how to read data from InputStream to a String –


How to get list of files using FileFilter class in java?

How to get list of files using FileFilter class in java?
DeeKay September 30, 2011 at 12:33 am · java.io

Below java code shows how to get list of files using FileFilter class. FileFilter is an abstract class used by JFileChooser for filtering the set of files shown to the user. A FileFilter can be set on a JFileChooser to keep unwanted files from appearing in the directory listing.   Reference: Java Docs


How to use BufferedInputStream: skip() method in java code?

How to use BufferedInputStream: skip() method in java code?
DeeKay September 21, 2011 at 8:46 pm · java.io

Below code shows how to use BufferedInputStream: skip() method in java –


How to use BufferedInputStream: reset() method in java code?

How to use BufferedInputStream: reset() method in java code?
DeeKay September 21, 2011 at 8:39 pm · java.io

Below code shows how to use BufferedInputStream: reset() method in java –