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 convert Array to List in java?

How to convert Array to List in java?
DeeKay October 6, 2011 at 7:39 pm · java.util

Below code example show how to convert an array to List in java. To convert array based data into list, we can use java.util.Arrays class. This class provide a static method asList(Object[] a) that converts array into list. OUTPUT: TOM JACK JILL JANE


How to convert an array into a collection object?

How to convert an array into a collection object?
DeeKay October 6, 2011 at 7:33 pm · java.util

Below java code example show how to convert an array into a Collection object. To convert array based data into list / collection, we can use java.util.Arrays class. This class provide a static method asList(Object[] a) that converts array into list / collection. OUTPUT: TOM JACK JILL JANE


How to get Date/Day, Month and Year of the current date?

How to get Date/Day, Month and Year of the current date?
DeeKay October 6, 2011 at 6:22 pm · java.util

Below java code example shows how to get date, month and year from the current date


How to convert String to Date in java?

How to convert String to Date in java?
DeeKay October 5, 2011 at 11:15 pm · java.util

Below code shows how to convert String to Date in java. It converts String Object to java.util.Date


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


Java Code Example for Hello World Program

Java Code Example for Hello World Program
DeeKay September 23, 2011 at 12:38 am · basic

Every beginner who starts programming in any language writes Hello World Program. Java Programmer is not exception for Hello World program. Below is the java version of Hello World Program. To start with Hello World java program you need to create HelloWorld.java file, Once you created file write class HelloWorld. The name of class and…
Continue Reading »


How to read file using FileChannel in java code?

How to read file using FileChannel in java code?
DeeKay September 22, 2011 at 6:25 pm · java.nio

Below java code shows example of how to read file using FileChannel –


Java Code Example for FileChannel in java NIO

Java Code Example for FileChannel in java NIO
DeeKay September 22, 2011 at 5:59 pm · java.nio

Below is the java code example for FileChannel of java.nio which shows how to use FileChannel to read file.


How to use a FileChannel to read data into a Buffer in java code?

How to use a FileChannel to read data into a Buffer in java code?
DeeKay September 22, 2011 at 5:41 pm · java.nio

Below Java code shows how to use FileChannel to read data into buffer. This is done by following below steps : Create FileInputStream for the file to be read Create FileChannel from FileInputStream Create ByteBuffer as channel reads data into buffer and set the limit of ByteBuffer. Read data from channel to byteBuffer To read…
Continue Reading »


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 –