Convert Byte Array to Hex using Java

The post briefs above how you can convert byte Array to Hex values and print those on terminal. You are mostly be needing this conversion when you work closely with byte operations like as needed in network communications etc. We will take the same example as we used in our another post “Byte Array To … Read more

Byte Array To Integer And Integer to Byte Array Conversion using JAVA

If you are working in some network related data transfer like sending some commands over socket, then its high likely that you will need to convert your integer command number to byte array before sending over socket since data sent over socket is only byte arrays. Following program briefs above how you can convert Byte … Read more

How to Switch between Java Versions on Ubuntu Linux ?

If you have installed multiple JDK on ubuntu and sometimes you might need to change the version of installed JAVA to get few things working with one version and few other things working with another version of JAVA. Lets first identify which all JDK are installed on your ubuntu, this can be done using “update-java-alternatives … Read more

How to check if Filepath is Normal File or Directory in JAVA ?

In our previous post, we seen how to identify if a file is present or Not using JAVA If you want to check whether certain filepath is a normal file or is a directory present in your disk before proceeding further to do some operations in JAVA, the java.io.File class provides an API “isFile()” and … Read more

How to check if File Exists in JAVA ?

If you want to check whether certain file is present or not in your disk before proceeding further to do some operations in JAVA, the java.io.File class provides an API “exists()” using which we can detect if file is present or not in your filesystem. $ vim FileExists.java As, we can see in above program, … Read more

Solved : java.net.BindException: Address already in use (Bind failed)

If you are working with TCP / UDP sockets in JAVA, there is higher chances your might have seen an exception like below, while trying to create a new socket on specific predefined port number instead of using dynamically allocated port number. Exception in thread “main” java.net.BindException: Address already in use (Bind failed) at java.net.PlainDatagramSocketImpl.bind0(Native … Read more

Writing TCP server and client socket programs in JAVA

As we have already seen, how to write UDP socket programs in JAVA, now we will write a sample TCP client and server in java. $ vim TcpReceiverServer.java Now, lets compile the run the server in one terminal as, $ javac TcpReceiverServer.java $ java TcpReceiverServer Waiting for client on port 5555… Here, server will be … Read more

Sending and receiving message as part of DatagramPacket using JAVA DatagramSocket ( JAVA DatagramSocket Client and Server Example )

$ vim DatagramSenderClient.java compile the client program as, [ Note: if you don’t have JAVA installed, follow “How to Install Java using apt-get command on Ubuntu” ] $ javac DatagramSenderClient.java Now, lets write a server program which will receive the data sent from the client. $ vim DatagramReceiverServer.java compile the server as, $ javac DatagramReceiverServer.java … Read more