Tagged: #java8

How to read a plain text file in Java

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...

How to iterate a Map in Java

How to iterate a Map in Java

This tutorial shows several ways for iterating a Map in Java. 1- Entry Set The common way for iterating a Map in Java is through entrySet() method as the following:...

How to iterate a List in Java

How to iterate a List in Java

This tutorial shows several ways for iterating a List in Java. 1- Typical For loop Using a typical For loop, you can iterate a List as the following:

2-...

Java - Convert InputStream to String

Java – Convert InputStream to String

This tutorial shows several ways to convert an InputStream to a String in Java. 1- BufferedReader The common way for generating a String out of an InputStream is through using...

Java - Convert InputStream to File

Java – Convert InputStream to File

This tutorial shows several ways to convert InputStream to File in Java. 1- Common way The common way for converting InputStream to File is through using OutputStream. You can’t directly...

Java - Convert List to Array

Java – Convert List to Array

This tutorial shows several ways to convert a List to Array in Java. 1- toArray() List provides a utility method called toArray() which accepts an empty array and populates it...

Java - Convert Array to List

Java – Convert Array to List

This tutorial shows several ways to convert Array to List in Java. 1- Arrays.asList You can convert an Array to List using Arrays.asList() utility method. This method accepts an array...

Java - Convert List to Map

Java – Convert List to Map

This tutorial shows the different ways to convert a List to Map in Java. 1- Java 7 & before With Java 7 and older releases, the only way to convert...