Core Java Category

Use ANT to Build a JAR MANIFEST.MF File

This tutorial look at how to use ant to create a Jar MANIFEST.MF file, as Prerequisites, please download Ant(http://ant.apache.org/bindownload.cgi) and install it. JAR file is a file format based on the popular ZIP file format and is used to aggregate many files into one, a JAR file is a essential zip file that contains an […]

Java MD5 example

Java MD5 Overview MD5 (Message-Digest algorithm 5) is a widely used cryptographic hash function with a 128-bit hash value, specified in RFC 1321, MD5 is one in a series of message digest algorithms designed by Professor Ronald Rivest of MIT (Rivest, 1994). MD5 has been employed in a wide variety of security applications, and is […]

Java Regular Expression to validate email address

A regular expression, specified as a string Pattern, be compiled into an instance of this class to search, edit or manipulate text and data. Today we guide how Java regular expression to validate the email address. we created a particular expression ^\\S+@\\S+$, then use it to match the email address: Way 1: validate email using […]

Java copy to clipboard

The clipboard is a set of functions and messages that enables applications to transfer data each other, Java implements the mechanism to transfer data using cut/copy/paste operations. This chapter demonstrate some examples about coping data to clipboard, clearing clipboard and reading existing clipboard contents. Java have system clipboard and local Clipboard, system clipboard is more […]

How to convert string to int in java

The propose of this tutorial is to guide you how to convert a string data to int in Java, it’s very basic skill for a Java developer. (1). Use method parseInt() in class Integer to covert string object to int. public class ConvertStringToInt { public static void main(String[] args){ String str = “124″; int strInt […]

How to sort an array in java

A Java array is an indexed table with a fixed number of slots, each slot holds a item, and all elements have the same type, this tutorial will demo how to sort an array in Java.

How do I Get User Application Data Directory in Java?

The Java program sometimes need to access the user application data directory, to save or get some temp or cache dates, the application data file path is defined as following:

The propose of this tutorial is to demonstrate how do I list all files In a directory in Java, unfortunately, such common function isn’t supported in JDK specification standard API.

Java Interview Swing Questions

Here list some java interview swing questions: Interview Questions (1):  What’s swing? Answer:  It is the Java graphical user interface (GUI) toolkit which is built on earlier Abstract Windowing Toolkit (AWT) libraries.  

How do I sort a Map by Key in Java

The elements in map are stored as {<”testkey1″, “value1″>, <”testkey2″, “value2″>, Map class makes no guarantees as to the order, it is unordered so that we can’t assume anything beyond that, in this how-to, we will look at how to sort a map by Key in Java. 1. Use HashMap sort the collections. Object[] key = map.keySet().toArray(); Arrays.sort(key); for (int […]