Convert String to InputStream in Java

In this tutorial, we will learn how to Convert String to InputStream in Java. While working on Strings, sometimes we come across big String that we want to process it incrementally or a small portion of it at a time. Then in this scenario, converting String to InputStream will be useful. InputStream is an abstract class representing an input stream of bytes. It implements the Closeable interface. This abstract class is the super class of all classes. Most of the methods in this class will throw an IOException on error…

Read More

Get size of LinkedHashMap in Java

In this tutorial, we will learn how to Get size of LinkedHashMap in Java. LinkedHashMap in Java is Hash table and Linked list implementation of the Map interface, with predictable iteration order. This implementation differs from HashMap in that it maintains a doubly-linked list running through all of its entries. It maintains a linked list of the entries in the map, in the order in which they were inserted. This allows insertion-order iteration over the map. That is, when iterating through a collection-view of a LinkedHashMap, the elements will be returned in the order in which they…

Read More

Get size of Hashtable in Java

In this tutorial, we will learn how to Get size of Hashtable in Java. Hashtable in Java stores key, value pairs. The keys and values cannot be null. The key in Hashtable is hashed, and the resulting hash code is used as the index at which the value is stored within the table. HashTable is similar to HashMap, but it is synchronized. Hashtable can only store objects that override the hashCode( ) and equals( ) methods that are defined in Object class. The hashCode( ) method computes and returns the hash code…

Read More