Java – Convert comma-separated String to List

This tutorial shows several ways for converting a comma-separated String to a List in Java. 1- Java 7 With Java 7 and older versions, the typical way of converting a comma-separated String to a List is through splitting the String by the comma “,” delimiter and then generating a List using Arrays.asList() as the following:

2- Java 8 In...

Disable save password prompt on login forms using CSS

Browsers automatically prompt users to save their password after login. In fact, this functionality provides a big advantage for allowing the user to login afterwards without reentering his credentials again. However, it also has its disadvantages and some people considers it as a security leak since anyone can view your saved passwords using the browser settings. In this tutorial, we...

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 BufferedReader as the following:

2- Scanner Another common way is to use a Scanner object as the following:

3- Java 8 With Java 8, you can generate a...

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 create a File object from InputStream. However, you can read the InputStream and write it to a File using FileOutputStream as the following:

2- java.nio (Java 8) Using nio...

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 with the elements of the array list.

In the above example, we initialize an array with the same number of elements as the input list, then we populate it...

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 as input and returns a list as output.

The limitation of using this method is that it returns a fixed size list. You can just read and overwrite its...

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 a List to Map is to iterate over the list and populate the map manually. In the following example, we implement a utility method which accepts a list of Student...

Spring cloud config server

Spring Cloud Config Server

Managing the configuration of microservices in a distributed system has been a tedious and time-consuming task especially if we’re talking about huge systems which consist of considerable amount of microservices. Each time you need to change the configuration of a microservice, you would go to the corresponding project, change its configuration and then restart the application for the change to...

Serve Static Resources with Spring Boot

In this tutorial we show how Spring Boot serves static resources like (html, js, css) in a web application. 1- Default path for static resources By default Spring Boot serves static resources defined under the following paths: /META-INF/resources/ /resources/ /static/ /public/ Except for index.html which is served as the root resource when accessing the root URL of a Spring Boot application,...

Spring Boot – How to solve OAuth2 ERR_TOO_MANY_REDIRECTS

#Problem When redirecting back to your application after a successful OAuth2 authentication, the following error occurs: #Solution This error occurs when the redirect URL set under the authorization service(Google, Facebook … etc) is not defined as a permitted URL inside your application. The permitted URL is the one which can be accessed without authentication. When the authorization service redirects to...