Java Tutorials

21. UDP Datagram sample program in Java

By: Jagan : 2022-09-15

Description: Datagrams are bundles of information passed between machines. They are somewhat like a hard throw from a well-trained but blindfolded catcher to the third baseman. Once the datagram has been released to its intended target, there is no assurance that it will arrive or even that someone will be there to catch it. Likewise, when the datagram is received, there is no assurance that it hasn't been damaged in transit or that whoever sent it is still there to receive a response.


22. A Simple whois program in Java

By: Henry : 2022-09-15

Description: The very simple example that follows opens a connection to a "whois" port on the InterNIC server, sends the command-line argument down the socket, and then prints the data that is returned. InterNIC will try to look up the argument as a registered Internet domain name, then send back the IP address and contact information for that site.


23. InetAddress get local and remote IP in Java

By: Grenfel : 2022-09-15

Description: The InetAddress class has no visible constructors. To create an InetAddress object, you have to use one of the available factory methods. Factory methods are merely a convention whereby static methods in a class return an instance of that class. This is done in lieu of overloading a constructor with various parameter lists when having unique method names makes the results much clearer. In the case of InetAddress, the three methods getLocalHost(), getByName(), and getAllByName() can be used to create instances of InetAddress. These methods are shown here:


24. A Serialization Example in Java

By: Fazal : 2022-09-15

Description: The following program illustrates how to use object serialization and deserialization. It begins by instantiating an object of class MyClass. This object has three instance variables that are of types String, int, and double. This is the information we want to save and restore.


25. StreamTokenizer sample program in Java

By: Emiley J : 2022-09-15

Description: StreamTokenizer defines several methods. In this example, we will use only a few. To reset the default set of delimiters, we will employ the resetSyntax() method. The default set of delimiters is finely tuned for tokenizing Java programs and is thus too specialized for this example. We declare that our tokens, or "words," are any consecutive string of visible characters delimited on both sides by whitespace.


26. PushbackReader sample program in Java

By: Daniel Malcolm : 2022-09-15

Description: The PushbackReader class allows one or more characters to be returned to the input stream. This allows you to look ahead in the input stream. Here are its two constructors:


27. BufferedReader sample program in Java

By: Charles : 2022-09-15

Description: As is the case with the byte-oriented stream, buffering an input character stream also provides the foundation required to support moving backward in the stream within the available buffer. To support this, BufferedReader implements the mark() and reset() methods, and BufferedReader.markSupported() returns true.


28. CharArrayWriter sample program in Java

By: Baski : 2022-09-15

Description: CharArrayWriter is an implementation of an output stream that uses an array as the destination. CharArrayWriter has two constructors, shown here:


29. CharArrayReader example program in Java

By: Abinaya : 2022-09-15

Description: CharArrayReader is an implementation of an input stream that uses a character array as the source. This class has two constructors, each of which requires a character array to provide the data source:


30. FileReader and FileWriter example program in Java

By: Tamil Selvan : 2022-09-15

Description: The FileReader class creates a Reader that you can use to read the contents of a file. FileWriter creates a Writer that you can use to write to a file.