• Convert OutputStream to byte array in java
    16 February

    Convert Outputstream to Byte Array in Java

    In this post, we will see how to convert OutputStream to Byte array in Java. Convert OutputStream to Byte array in Java Here are steps to convert OutputStream to Byte array in java. Create instance of ByteArrayOutputStream baos Write data to ByteArrayOutputStream baos Extract byte[] using toByteArray() method. [crayon-628acf9284c05976282511/] Output: Print output: Java2blog Convert OutputStream […]

  • 08 August

    Difference between Scanner and BufferReader in java

    In this post, we will see difference between Scanner and BufferReader in java. Java has two classes that have been used for reading files for a very long time. These two classes are Scanner and BufferedReader. In this post, we are going to find major differences and similarities between the two classes. Introduction Let’s first […]

  • 29 March

    Read UTF-8 Encoded Data in java

    In this post, we will see how to read UTF-8 Encoded Data. Sometimes, we have to deal with UTF-8 Encoded Data in our application. It may be due localization or may be processing data from user input. There are multiple ways to read UTF-8 Encoded Data in Java. Using Files’s newBufferedReader() We can use java.nio.file.Files's […]

  • 29 March

    Write UTF-8 Encoded Data in java

    In this post, we will see how to write UTF-8 Encoded Data. Sometimes, we have to deal with UTF-8 Encoded Data in our application. It may be due localization or may be processing data from user input. We will use Hindi language sentences to write in file. There are three ways to write UTF-8 Encoded […]

  • 15 March

    Java read file line by line

    In this post, we will see different ways to read file line by line in java. Sometimes, we need to read file line by line to a String, and process it. Here are different ways to read file line by line in java. Java 8 Streams Java 8 has introduced a new method called lines() […]

  • 05 October

    Java FileReader Example

    The FileReader class of java.io package provides a seamless and easy-to-use way to read and analyse the contents of a file using Java. The FileReader class, works similar to the FileInputStream class because it reads the file data as a stream. However, unlike the latter which reads files as a stream of bytes, FileReader reads […]

  • 08 June

    Java – Create new file

    There are many ways to create a file in java. Creating a file is a very easy task. We will learn 5 different ways to Create a file. Using java.io.File class’s createNewFile method This is simplest and oldest way to create file.Here is simple snapshot to create a file in java. [crayon-628acf928ce15408799421/] Using java.nio.file.Files from […]

  • 06 February

    Java FileWriter Example

    The FileWriter class of java.io package makes writing to files in Java as easy as A-B-C. The FileWriter class writes to files as a stream of characters instead of bytes(as in FileOutputStream). Like its input-oriented counterpart FileReader, the FileWriter class is intended for writing “text” based files one character at a time. Let us look […]

  • 18 February

    Working with formulas in excel using Apache POI in java

    Java Apache POI tutorial: Read excel files in java using POI Write excel files in java using POI Working with formula in excel using POI How to set style in excel using POI In this post, we will see how to set and evaluate formulas in excel using Apache POI. Set formula for a cell: […]