Samual Sam has Published 2492 Articles

Java Program to convert Properties list into a Map

Samual Sam

Samual Sam

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

571 Views

To convert Properties list into a map, let us first create an object of Properties class −=Properties p = new Properties();Now, use setProperty() to set key-value pair −p.setProperty("P", "1"); p.setProperty("Q", "2"); p.setProperty("R", "3"); p.setProperty("S", "4"); p.setProperty("T", "5"); p.setProperty("U", "6");With that, the following is how the Properties list is converted into ... Read More

Create a temporary file in Java

Samual Sam

Samual Sam

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

6K+ Views

A temporary file can be created using the method java.io.File.createTempFile(). This method requires two parameters i.e. the prefix to define the file name and the suffix to define the file extension. It also returns the abstract path name for the temporary file created.A program that demonstrates this is given as ... Read More

CharBuffer array() method in Java

Samual Sam

Samual Sam

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

97 Views

A char array for the buffer can be obtained using the method array() in the class java.nio.CharBuffer. If the returned array is modified, then the contents of the buffer are also similarly modified and vice versa. If the buffer is read-only, then the ReadOnlyBufferException is thrown.A program that demonstrates this ... Read More

LocalDateTime getYear() method in Java

Samual Sam

Samual Sam

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

364 Views

The year for a particular LocalDateTime can be obtained using the getYear() method in the LocalDateTime class in Java. This method requires no parameters and it returns the year which can range from MIN_YEAR to MAX_YEAR.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo ... Read More

How to create a Queue from LinkedList in Java?

Samual Sam

Samual Sam

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

298 Views

Let us create a queue from LinkedList like this −Queuequeue = new LinkedList(); queue.add("P"); queue.add("Q"); queue.add("R"); queue.add("S"); queue.add("T"); queue.add("U"); queue.add("V");Now, use a List to display the elements of the queue −Listlist = new ArrayList(queue);Example Live Demoimport java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Queue; public class Demo {    public static void ... Read More

How to export specific column data in MySQL?

Samual Sam

Samual Sam

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

732 Views

To export specific column data in MySQL, use OUTFILE −select yourColumnName from yourTableName into outfile 'yourLocationOfFile’;Let us first create a table −mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentFirstName varchar(20),    StudentLastName varchar(20) ); Query OK, 0 rows affected (0.54 sec)Insert records in ... Read More

Create temporary file in specified directory in Java

Samual Sam

Samual Sam

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

2K+ Views

A temporary file in the specified directory can be created using the method java.io.File.createTempFile(). This method requires three parameters i.e. the prefix to define the file name, the suffix to define the file extension and the directory in which the temporary file is to be created. It also returns the ... Read More

CharBuffer get() method in Java

Samual Sam

Samual Sam

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

78 Views

The value at the current position of the buffer is read and then incremented using the method get() in the class java.nio.CharBuffer. This method returns the value that is at the current buffer position. Also, the BufferUnderflowException is thrown if underflow situation occurs.A program that demonstrates this is given as ... Read More

LocalDateTime getDayOfYear() method in Java

Samual Sam

Samual Sam

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

39 Views

The day of the year for a particular LocalDateTime can be obtained using the getDayOfYear() method in the LocalDateTime class in Java. This method requires no parameters and it returns the day of the year which can be in the range of 1 to 365 and also 366 for leap ... Read More

What is cumulative acknowledgement?

Samual Sam

Samual Sam

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

4K+ Views

In data communications, when a receiver receives a message, it sends an acknowledgement back to the sender to notify it about correct receipt of the message. Cumulative acknowledgement is a process in which the receiver sends a single acknowledgement in response to a finite number of frames received. Through this, ... Read More

Advertisements