How to convert String to Date

In this post we will see how to convert String to date in java. For this we will use SimpleDateFormat API to convert string to date. We need to pass in the dateformat in which we want to convert String to date

Read More

How to compare Strings in java

We can compare Strings in java either using [crayon-5b5515a0dfe15228964344-i/] or [crayon-5b5515a0dfe1e702686769-i/] depending on how the String was created. Using == to compare Strings in java == operator will check the reference of the Strings. If the references are same then == will

Read More

How to convert String to boolean

In Java we have multiple ways to convert String to boolean. We will see a few of those ways in this post. 1. Convert String to boolean using Boolean.parseBoolean() For Any value of string other than “true” (case insensitive), parseBoolean() will return

Read More

How to convert String to int

In Java we have multiple ways to convert String to int. We will see a few of those ways in this post. 1. Convert String to int using Integer.parseInt() [crayon-5b5515a0e094e797467496/] If the String value doesn’t contain all digits OR if the String

Read More

String Pool in Java and String Initialization

How to Create a String As we know that String in java can be created using 2 types. 1. Direct initialization [crayon-5b5515a0e0f4a617900717-i/] 2. Using a new operator [crayon-5b5515a0e0f53738428106-i/] Difference between these 2 types Before going to the differences, we will first understand

Read More

Spring MVC Password tag Example

Spring MVC password tag is used to show a password field on the UI [crayon-5b5515a0e14b9869997841/] The HTML code that gets generated is [crayon-5b5515a0e14c2919387968/] You can get more information on the various attributes that can be used in the password tag at the

Read More

How to Create Dir in java

We can create dir in java either using [crayon-5b5515a0e19ea690147992-i/] or [crayon-5b5515a0e19f2842507333-i/]. Example: Create Dir in java using File.mkdir() [crayon-5b5515a0e19f7796887916/] File.mkdir is used to create a directory that is given in the path. If we specify “C:\\kscodes\\work” as in the above example, then

Read More

How to Copy File in java

There are many ways in which you can copy file in java. Example : Copy File in java using InputStream/OutStream In the first example we will see the traditional way of copying file using the InputStream/OutStream. This is the method used prior

Read More

How to Rename file in Java

In this post we will see an example on how we can rename file in java. We will use the File.renameTo(File dest) method. [crayon-5b5515a0e2356086842981-i/] renames the current file with the name of the file in the param. In other words renameTo will

Read More

How to Delete File in java

In this post we will see an example on how we can delete file in java. We will see examples of the File.delete() and File.deleteOnExit() methods in detail Example : Delete File in java using File.delete() [crayon-5b5515a0e27c6757564184/] [crayon-5b5515a0e27cf906869384-i/] returns “true” if a

Read More