Krantik Chavan has Published 308 Articles

How can we retrieve file from database using JDBC?

Krantik Chavan

Krantik Chavan

Updated on 27-Jun-2020 06:18:17

893 Views

The ResultSet interface provides the methods named getClob() and getCharacterStream() to retrieve Clob datatype, In which the contents of a file are typically stored.These methods accept an integer representing the index of the column (or, a String value representing the name of the column) and retrieves the value at the ... Read More

Remove substring from StringBuilder in Java

Krantik Chavan

Krantik Chavan

Updated on 26-Jun-2020 15:00:46

8K+ Views

In order to remove a substring from a Java StringBuilder Object, we use the delete() method. The delete() method removes characters in a range from the sequence. The delete() method has two parameters, start, and end. Characters are removed from start to end-1 index.Declaration − The java.lang.StringBuilder.delete() method is declared ... Read More

Convert UTF-8 to Unicode in Java

Krantik Chavan

Krantik Chavan

Updated on 26-Jun-2020 13:46:57

5K+ Views

Before moving onto their conversions, let us learn about Unicode and UTF-8.Unicode is an international standard of character encoding which has the capability of representing a majority of written languages all over the globe. Unicode uses hexadecimal to represent a character. Unicode is a 16-bit character encoding system. The lowest ... Read More

Print stack trace in Java

Krantik Chavan

Krantik Chavan

Updated on 26-Jun-2020 13:32:02

5K+ Views

In order to print the stack trace in Java, we use the java.lang.Throwable.printStackTrace() method. The printStackTrace() method prints the throwable and its backtrace in the standard error stream.Declaration - The java.lang.Throwable.printStackTrace() method is declared as follows −public void printStackTrace()Let us see a program to print the stack trace in Java.Example Live ... Read More

MongoDB $push in nested array?

Krantik Chavan

Krantik Chavan

Updated on 26-Jun-2020 08:36:51

833 Views

Here, $push can be used to add new documents in nested array. To understand the above $push concept, let us create a collection with nested array document. The query to create a collection with document is as follows:>db.nestedArrayDemo.insertOne({"EmployeeName":"Larry", "EmployeeSalary":9000, "EmployeeDetails":    [{"EmployeeDOB":new Date('1990-01-21'), "EmployeeDepartment":"ComputerScience", "EmployeeProject":    [{"Technology":"C", "Duration":6}, {"Technology":"Java", "Duration":7}]}]});The ... Read More

Format a message with date in Java

Krantik Chavan

Krantik Chavan

Updated on 26-Jun-2020 07:32:31

415 Views

To format the message with date in Java, we use the MessageFormat class and the Date class. The MessageFormat class gives us a way to produce concatenated messages which are not dependent on the language. The MessageFormat class extends the Serializable and Cloneable interfaces.Declaration - The java.text.MessageFormat class is declared as ... Read More

Medium length style format for Date with Java MessageFormat class

Krantik Chavan

Krantik Chavan

Updated on 26-Jun-2020 07:28:36

99 Views

To format message with medium style format of date in Java, we use the MessageFormat class and the Date class. The MessageFormat class gives us a way to produce concatenated messages which are not dependent on the language. The MessageFormat class extends the Serializable and Cloneable interfaces.Declaration − The java.text.MessageFormat ... Read More

Display thread's information in Java

Krantik Chavan

Krantik Chavan

Updated on 26-Jun-2020 06:55:04

3K+ Views

In order to get the name of the Thread, we use the getName() method in Java. This method returns the name of the thread.Declaration − The java.lang.Thread.getName() method is declared as follows −public String getName()In order to get the identity of the Thread, we use the getId() method in Java. ... Read More

How to handle Assertion Error in Java?

Krantik Chavan

Krantik Chavan

Updated on 25-Jun-2020 15:15:59

6K+ Views

In order to handle the assertion error, we need to declare the assertion statement in the try block and catch the assertion error in the catch block.Let us see a program on how to handle Assertion Error in Java −Examplepublic class Example {    public static void main(String[] args) throws ... Read More

Validate Phone with Java Regular Expressions

Krantik Chavan

Krantik Chavan

Updated on 25-Jun-2020 15:01:54

271 Views

In order to match the phone using regular expression, we use the matches method in Java. The java.lang.String.matches() method returns a boolean value which depends on the matching of the String with the regular expression.Declaration − The java.lang.String.matches() method is declared as follows −public boolean matches(String regex)Let us see a ... Read More

Advertisements