Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

 

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

 

and many more ....

 

 

Get response headers from HTTP request

With this example we are going to demonstrate how to get response headers from an HTTP request in Java. In short, to get the response headers from an HTTP request you should : Create a URL Object that represents the resource you want to access Use the openConnection() API method of the URL Object to access connection specific parameters for ...

Read More »

Send cookie with HTTP request

This is an example of how to send a cookie with an HTTP request in Java. In short, to send cookies with HTTP requests one should : Create a URL Object that represents the resource you want to access Use the openConnection() API method of the URL Object to access connection specific parameters for the HTTP request Use the setRequestProperty() ...

Read More »

Get cookies from HTTP connection

With this example we are going to demonstrate how to get cookies from an HTTP connection in Java. In short, to retrieve cookie information of a URL connection you should Create a URL Object that represents the resource you want to access Use the openConnection() API method of the URL Object to access connection specific parameters for the HTTP request ...

Read More »

Convert Between Character Set Encodings with CharBuffer

In this example we shall show you how to convert between character set encodings with a CharBuffer in Java. To achieve character set conversions in Java one should perform the following steps: Use the Charset class to get the Charset object for utilizing the specific character set Use the newDecoder() API method of the Charset object to construct a new ...

Read More »

Convert String to byte array UTF encoding

With this example we are going to demonstrate how to convert a String to byte array and vice-versa using the default character encoding in Java. In short, to perform the aforementioned conversion, we are going to use classes from the NIO package in Java so as to convert every character from the target String to its byte equivalent. Namely we ...

Read More »

Create Stream from FileChannel

This is an example of how to create input and output streams to read and write data from/to a file in Java. Doing reads and writes of data using Java NIO Channels implies that you should : Create a File object to encapsulate an actual file in the file system To read data from the file you should create a ...

Read More »

Write to Channel with ByteBuffer

With this example we are going to demonstrate how to write data to a NIO Channel using a ByteBuffer in Java. In particular we are going to read data from a specific file in the file system and write them to a destination file. In short what we do is the following : To write data to a channel you ...

Read More »

Read from Channel with ByteBuffer

This is an example of how to read data from a NIO Channel using a ByteBuffer in Java. In particular we are going to read data from a specific file in the file system and print them on screen. In short what we do is the following : To read data from channel you should create a ReadableByteChannel. To do ...

Read More »

Create memory mapped file

This is an example of how to create a memory mapped file in Java. Doing reads and writes of data using Java NIO Channels implies that you should : Create a File object to encapsulate an actual file in the file system Create a random access file stream (read only, read-write). To do so you must first create a RandomAccessFile ...

Read More »