Tagged: #java7

How to write to a plain text file in Java

This tutorial shows several ways to write content to a text file in Java. The techniques used below are pure JDK and don’t use external libraries. 1- BufferedWriter The most common and efficient way to write content to a file in Java is through using BufferedWriter as the following:

This technique is very efficient for writing huge data to...

How to read a plain text file in Java

This tutorial shows several ways for reading plain text files in Java. The techniques we use here are totally JDK built-in and don’t depend on external libraries. 1- BufferedReader The most common way for reading plain text files in Java is through using a FileReader wrapped by a BufferedReader. This technique is very efficient for reading large text files.

...

Java – Convert File to byte[]

This tutorial shows several ways to convert a File object to a byte[] array in Java. 1- Traditional way The traditional conversion way is through using read() method of InputStream as the following:

2- Java NIO With Java 7, you can do the conversion using Files utility class of nio package:

3- Apache Commons IO Besides JDK, you can...

Java – Convert byte[] to File

This tutorial shows several ways to convert a byte[] array to File in Java. 1- Traditional way The traditional way of doing the conversion is through using FileOutputStream as the following:

2- Java NIO With Java 7, you can do the conversion using Files utility class of nio package:

3- Apache Commons IO Besides JDK, you can do...