Top 15 Eclipse Keyboard Shortcuts for Java Developers

This tutorial shows the most commonly used keyboard shortcuts while developing a Java application using Eclipse IDE. Top 15 Eclipse shortcuts 1- CTRL-SHIFT-R: used to look for a specific resource in the work space, the resource could be (java class, XML, HTML, JS, .properties …etc). It’s allowed to use * in the search box if you’re not sure about the...

Download file from a Web Application using Servlet

This tutorial shows how to download a file from a web application using Servlet. A typical task in most web applications is to download files stored at the server side to the client’s machine, here below we provide the common way of doing this with Servlet. 1- Download File Servlet Below is an example of a typical Servlet which downloads files...

Convert JSON to Java Object

This tutorials shows 2 ways for converting a JSON string to a Java object. 1- Gson Gson is the most popular library for converting JSON string to Java objects. With Gson, you can do the conversion in one line as the following:

Some points to be considered when using Gson: If the JSON string holds an invalid object attribute, then Gson implicitly...

Convert Java object to JSON

This tutorial shows 2 ways for converting Java objects to JSON. This kind of conversion is normally done via third-party libraries as it’s not supported by the JDK itself and requires a hard work to do it manually. 1- Gson The most popular library used for converting Java objects to JSON is the Google Gson library. Using Gson, you can...

Java – Convert List to comma-separated String

This tutorial shows several ways for converting a List to a comma-separated String in Java. 1- Java 7 The traditional way of converting a List to a comma-separated String in Java 7 and older versions is through using StringBuilder as the following:

2- Java 8 In Java 8, there are 2 conversion ways. 2.1. String.join() The most common way is...

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