Karthikeya Boyini has Published 2193 Articles

How to write a for loop in a JSP page?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

7K+ Views

Following is the for loop example − FOR LOOP Example JSP Tutorial The above code will generate the following result −JSP Tutorial JSP Tutorial JSP Tutorial

ByteBuffer allocate() method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

425 Views

A new ByteBuffer can be allocated using the method allocate() in the class java.nio.ByteBuffer. This method requires a single parameter i.e. the capacity of the buffer. It returns the new ByteBuffer that is allocated. If the capacity provided is negative, then the IllegalArgumentException is thrown.A program that demonstrates this is ... Read More

How to treat NULL as 0 and add columns in MySQL?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

612 Views

Use the concept of IFNULL() method to treat NULL as 0. Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Value1 int,    Value2 int ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using ... Read More

ByteBuffer asIntBuffer() method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

115 Views

A view of the ByteBuffer can be created as an IntBuffer using the asIntBuffer() method in the class java.nio.ByteBuffer. This method requires no parameters and it returns an int buffer as required. This buffer reflects the changes made to the original buffer and vice versa.A program that demonstrates this is ... Read More

How to get the Checksum of a Byte Array in Java?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

1K+ Views

Create a Byte Array for which you want the Checksum −byte[] arr = "This is it!".getBytes();Now, create a Checksum object −Checksum checksum = new Adler32(); checksum.update(arr, 0, arr.length);The update() above updates the current checksum with the specified array of bytes.Now, get the checksum with getValue() method, which gives the current ... Read More

How do you select from MySQL where last value in a string = x?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

254 Views

You can use LIKE operator with wildcards to select the records where last value in a string = x, for example ‘10’, ‘15’, etc.Let us first create a table −mysql> create table DemoTable (    ClientId varchar(20) ); Query OK, 0 rows affected (0.68 sec)Insert records in the table using ... Read More

CharBuffer put() method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

127 Views

The required value can be written at the current position of the buffer and then the current position is incremented using the method put() in the class java.nio.CharBuffer. This method requires a single parameter i.e. the value to be written in the buffer and it returns the buffer in which ... Read More

Java Program to convert java.util.Date to ZonedDateTime

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

3K+ Views

Create a Date object −Date date = new Date();Now, set the ZonedId to default −final ZoneId id = ZoneId.systemDefault();Convert java.util.date to ZonedDateTime −System.out.println(ZonedDateTime.ofInstant(date.toInstant(), id));Example Live Demoimport java.time.ZoneId; import java.time.ZonedDateTime; import java.util.Date; public class Demo {    public static void main(String[] args) {       Date date = new Date();   ... Read More

Rename file or directory in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

423 Views

The method java.io.File.renameTo() is used to rename a file or directory. This method requires a single parameter i.e. the name that the file or directory is renamed to and it returns true on the success of the renaming or false otherwise.A program that demonstrates this is given as follows −Example Live ... Read More

LocalTime plusHours() method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

76 Views

An immutable copy of a LocalTime object where some hours are added to it can be obtained using the plusHours() method in the LocalTime class in Java. This method requires a single parameter i.e. the number of hours to be added and it returns the LocalTime object with the added ... Read More

Advertisements