devxlogo

Java

Using a Java File with an Empty Main Method

This is sort of like cheating the Java runtime. Ideally, I believe, starting Java 1.6, you cannot execute Java programs without a standard main method. Prior to that, only the

Using the Serialver Tool

Java provides a mechanism to know the serialization properties of a given class. Command: serialver -show The above command will bring up a window titled Serial Version Inspector with fields

Finding All Digits in a Given String

This regex will help you retrieve all the digits that are present in the string. Regex is powerful and makes this a simple procedure. public class FindAllDigitsInString{ public static void

Converting a String into a Date

The parse() method from SimpleDateFormat class helps to convert a String pattern into a Date object. DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);String dateStr = “08/30/2018”; // input StringDate date = dateFormat.parse(dateStr);System.out.println(date.getYear()); There are

Convert an Operand to a String

When one of the two operands is not a string, it is converted to a String as follows: an operand whose type is a primitive type is converted as if by

Moving a File Using Java

It may be required to move a file or file(s) based on a requirement. The following Java APIs help us achieve this. The code snippet below illustrates moving file a.png

Building Javadocs from the Command Line

Some IDEs provide support for generating HTML from Javadocs automatically, but this can also be achieved using the command line: javadoc tool The most basic usage of the tool is