0% found this document useful (0 votes)
16 views21 pages

Unit - I Networking

Uploaded by

thirosul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views21 pages

Unit - I Networking

Uploaded by

thirosul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Networking

 Networking Basics :-
A) Protocol :-
 A protocol is a set of rules and standards for communication.
 A protocol specifies the format of data being sent over the Internet, along with
how and when it is sent.
 On the other end of the communication, the protocol also defines how the data
is received along with its structure and what it means.
 There are three important protocols used in the Internet.

1) IP (Internet Protocol): Is a network layer protocol that breaks data into small
packets and routes them using IP addresses.

2) TCP (Transmission Control Protocol): This protocol is used for connection


oriented communication between two applications on two different machines.
It is most reliable and implements a connection as a stream of bytes from
source to destination. TCP takes care of number of bits sent and whether all the
bits are received duly by the destination computer. So it is called 'connection
oriented reliable protocol'. Every transmitted bit is accountable in this protocol.
Hence, this protocol is highly suitable for transporting data reliably on a
network.

3) UDP (User Datagram Protocol): It is a connection less protocol and used


typically for request-reply services. It will not check how many bits are sent or
how many bits are actually received at the other side. During transmission time
of data, there may be loss of some bits. Therefore is an unreliable protocol. It is
less reliable but faster than TCP.

B) Addressing :-
 Each machine on the network is uniquely identified by a physical address.
 This address is the address of the network interface card (LAN card) and is
called the MAC address which is a 48 bit address represented as 12
hexadecimal characters.
 For example: 00:09:5B:EC:EE:F2
 However, to identify machines across networks, a global addressing scheme
is needed.
Prof. Babar Patil R. M. Page 1
 The internet uses IP address to uniquely identify a network and a machine
in the network.
 The IP address is a logical address.
 The IPv4 addresses are 32 bit and the IPv6 addresses are 128 bits.
 Example: IPv4-192.168.100.24
 IPv6 0001:0BA0:01E0:D001:0000:0000:D0F0:0010
 Any communication between multiple networks in the internet is done using
IP addresses.
 Another address that is used by the transport layer for communication is the
port address which identifies the application.

C) Domain Name System (DNS):-


 It is very difficult to remember the IP addresses of machines in a network.
 For example, 81.23.103.55 is an IP address. Instead, we can identify a
machine using a "domain name" which is a character based naming
mechanism.
 For example, www.google.com is a domain name.
 The mapping between the domain name and the IP address is done by a
service called DNS.
 DNS is the service used to convert human readable names of hosts to IP
addresses.
 DNS name is nothing but resolving host names, such as www.yahoo.com,
to their corresponding IP addresses.
 The DNS is basically a large database which resides on various computers
and it contains the names and IP addresses of various hosts on the internet
and various domains.
 While every device on the Internet has an IP address such as 81.23.103.55,
humans generally find it easier to refer to machines by names, such as
www.google.com. DNS provides a mechanism for mapping back and forth
between IP addresses and host names.

 DNS is a system that is used to map the user friendly host names to their
IP addresses and vice versa and used over the Internet.
 Basically, there are a number of DNS servers on the Internet, each
listening through UDP software to a port. When a computer on the Internet
needs DNS services-for example, to convert a host name such as
www.google.com to a corresponding IP address-it uses the UDP software
running on its system to send a UDP message to one of these DNS servers,
requesting the IP address.

Prof. Babar Patil R. M. Page 2


D) URL :-
 A URL (Uniform Resource Locator) is a unique identifier for any resource
located on the Internet. It has the following structure.
<protocol>:// <hostname> [:<port>] [/<pathname>] [/<filename>
[#<section>]]
 For example, https://www.tutorialspoint.com/java/java_tutorial.pdf
 Here, the domain name is tutorialspoint.com.

E) Sockets :-
 It is possible to establish a logical connecting point between a server and a
client so that communication can be done through that point. This point is
called socket.
 A socket is a bi-directional communication channel between hosts i.e., a
computer on a network often termed as host.
 A socket is a point of connection between a server and a client on a
network.
 A socket represents the end-point of a network communication.
 Sockets provide a simple read/write interface and hide the implementation
details network and transport layer protocols.
 When a client wishes to make connection to a server, it will create a socket
at its end of the communication link.
 In Java sockets are created with the help of certain classes and these
classes are found in the java.net package.
 There are separate classes in the java.net package for creating TCP sockets
and UDP sockets.
 The client socket is created with the help of the Socket class and the server
socket is created using the ServerSocket class
 The socket concept was developed in the first networked version of UNIX
developed at the University of California at Berkeley.
 So sockets are also known as Berkeley Sockets.

Prof. Babar Patil R. M. Page 3


Fig: Concept of Socket

F) Ports :-
 A port number identifies a specific application running in the machine.
 A port is a number in the range 1-65535.
 It is a transport layer address used by TCP and UDP to handle
communication between applications.
 For example, an email application on one machine wants to communicate
with an email application on another machine.
 The machines are identified by the IP addresses but the email applications
are identified by the port numbers at which they communicate i.e. Port 25.
 Reserved Ports:
 TCP/IP protocol reserves port number in the range 1-1023 for the use of
specified standard services, often referred to as well-known port.
 The following table lists some reserved ports and their services.

Protocol Description Port

FTP File Transfer 21

HTTP Hypertext Transfer 80

SMTP Mail Transfer 25

TELNET Remote Login 23

POP Accesses mail boxes 109

Prof. Babar Patil R. M. Page 4


H) Client/Server :-
 This is a common term related to networking.
 A server is a machine that has some resource that can be shared.
 In client/ server networking the client makes as service request to server
then server fulfill (response) to client request.
 For example, a computing server, which provides computing capability; a
print server which provides network printing facility, a disk server which
provide networked disk space, and web server which stores web pages.
 It performs tasks like authentications, filtering and buffering of data etc.
 It communicates with the server on behalf of the client.
 A client is simply any machine that wants to use the services of a
particular server.
 The server is a permanently available resource, while the client is free to
disconnect after it's job is done.

 Networking Classes and Interfaces:-


 Java supports TCP/IP both by extending the already established stream
I/O interface and by adding the features required to build I/O objects
across the network.
 Java supports both the TCP and UDP protocol families.
 TCP is used for reliable stream-based I/O across the network.
 UDP supports a simpler, hence faster, point-to-point datagram-oriented
model.
 Java is a premier language for network programming.
 The java.net package encapsulate large number of classes and interface
that provides an easy-to use means to access network resources.

Here are some important classes and interfaces of java.net package.


java.net Classes:

InetAddress URL Socket Datagrampacket

URLConnection ServerSocket DatagramSocket CachwRequest

Through the classes in java.net, Java programs can use TCP or UDP to
communicate over the Internet. The URL, URLConnection, Socket, and

Prof. Babar Patil R. M. Page 5


ServerSocket classes all use TCP to communicate over the network. The
DatagramPacket, DatagramSocket, and MulticastSocket classes are for use with
UDP.
1. InetAddress: This class represents an Internet Protocol (IP) address.
2. URLConnection: Java URL Class present in java.net package, deals with
URL (Uniform Resource Locator) which uniquely identify or locate
resources on internet.
3. Socket: The java.net.Socket class represents the socket that both the client
and the server use to communicate with each other.
4. ServerSocket: The java.net.ServerSocket class is used by server applications
to obtain a port and listen for client requests.
5. DatagramPacket: It creates a datagram packet.
6. DatagramSocket: Java DatagramSocket class represents a connection-less
socket for sending and receiving datagram packets.

 InetAddress :-
 The java.net.InetAddress class provides methods to get the IP address of
any hostname.
 An IP address is represented by 32-bit or 128-bit unsigned number.
 InetAddress can handle both IPv4 and IPv6 addresses.
 The InetAddress class is used to encapsulate both, the numerical IP address
and the domain name for that address.
 We interact with this class by using the name of an IP host, which is more
convenient and understandable than its IP address.
 The InetAddress class hides the number inside.
 The InetAddress class has no visible constructors.
 The InetAddress class has the inability to create objects directly,
hence factory methods are used for the purpose.
 Factory Methods are static methods in a class that return an object of that
class.

Factory methods: -
There are 5 factory methods available in InetAddress class –

1) static InetAddress getLocalHost() throws UnknownHostException


This method returns the instance of InetAddress containing the local
hostname and address.

Prof. Babar Patil R. M. Page 6


2) public static InetAddress getByName( String host ) throws
UnknownHostException
This method returns the instance of InetAddress containing LocalHost
IP and name.

3) static InetAddress[] getAllByName( String hostName ) throws


UnknownHostException
This method returns the array of the instance of InetAddress class which
contains IP addresses. It returns an array of InetAddress object from the
specified hostname, as a hostname can be associated with several IP
addresses.

4) static InetAddress getByAddress( byte IPAddress[] ) throws


UnknownHostException
This method returns an InetAddress object created from the raw IP
address.

5) static InetAddress getByAddress( String hostName, byte IPAddress[]


) throws UnknownHostException
This method creates and returns an InetAddress based on the provided
hostname and IP address.

Program 1:-
Below is the Java implementation of InetAddress class to demonstrate the use of
factory methods –

import java.io.*;
import java.net.*;
import java.util.*;

class abc {
public static void main(String[] args) throws UnknownHostException
{
// To get and print InetAddress of Local Host

Prof. Babar Patil R. M. Page 7


InetAddress address1 = InetAddress.getByName(“www.google.com”);
System.out.println("Host Name : " + address1.getHostName());
System.out.println("Host Name : " + address1.getHostAddress());
}
}

Program 2:-

import java.io.*;
import java.net.*;
import java.util.*;

class abc {
public static void main(String[] args) throws UnknownHostException
{
// To get and print InetAddress of Local Host
InetAddress address1 = InetAddress.getLocalHost();
System.out.println("InetAddress of Local Host : " + address1);

// To get and print InetAddress of Named Host


InetAddress address2 = InetAddress.getByName("45.22.30.39");
System.out.println("InetAddress of Named Host : " + address2);

// To get and print ALL InetAddresses of Named Host


InetAddress address3[] = InetAddress.getAllByName("172.19.25.29");
for (int i = 0; i < address3.length; i++) {
System.out.println("ALL InetAddresses of Named Host : " + address3[i]);
}

// To get and print InetAddresses of


// Host with specified IP Address
byte IPAddress[] = { 125, 0, 0, 1 };
InetAddress address4 = InetAddress.getByAddress(IPAddress);
System.out.println("InetAddresses of Host with specified IP Address : "
+ address4);

}
}

Output :-
InetAddress of Local Host : localhost/127.0.0.1
InetAddress of Named Host : /45.22.30.39
ALL InetAddresses of Named Host : /172.19.25.29
InetAddresses of Host with specified IP Address : /125.0.0.1

Prof. Babar Patil R. M. Page 8


InetAddress — Instance Methods :
InetAddress class has plenty of instance methods that can be called using the
object. The instance methods are –
1) boolean equals(Object obj)
Compare this object with specified object and returns true if this object has the
same Internet address as other.

2) byte[] getAddress()
This method returns the IP address associated with this object as an array of
bytes in network order.

3) String getHostAddress()
This method returns a string representation of the IP address associated with
this object. For example: "206.175.64.78".

4) String getHostName()
Returns the hostname associated with this object.

5) Int hashCode()
Returns the hashcode based on the IP address of the object.

6) boolen isMulticastAddress()
True if this object represents a multicast address; false otherwise.

7) String toString()
This method returns a String that contains both the hostname and IP address of
this object.

Program:
Using Instance methods of InetAddress class.

import java.net.*;
public class NetDemo {
public static void main(String[] args)
{ try {
InetAddress i = InetAddress.getLocalHost();
System.out.println("Local Address: " + i);

InetAddress i1 = InetAddress.getByName("www.google.com");
System.out.println("Host Address: " + i1);

System.out.println("Host Address: " + i1.getHostAddress());


System.out.println("Host Address: " + i1.getAddress());
Prof. Babar Patil R. M. Page 9
System.out.println("Host Address: " + i1.getHostName());
}
catch (Exception e) {
System.out.println(e);
}
}
}
OutPut:-
Local Address: DESKTOP-D7GKJBG/169.254.39.121
Host Address: www.google.com/142.251.42.100
Host Address: 142.251.42.100
Host Address: [B@404b9385
Host Address: www.google.com

 TCP/IP Programming :-
 A socket is one of a two way communication link between two programs
running on the computer network.
 A socket is bound to a port number so that the TCP layer can identify the
application that data is destined to be sent.
 Java offers good support for TCP socket, in the form of two socket
classes,
1) java.net.Socket
2) java.net.ServerSocket
 Th java.net.Socket class represents a TCP client socket, which connect to
server socket and infinite protocol exchange.
 The java.net.ServerSocket class is used to create a server that listens for
incoming connections from one or more clients.
 Two TCP class are – Socket class and ServerSocket class.

1) Socket Class :-
 It is possible to establish a logical connecting point between a server and a
client so that communication can be done through that point.
 This point is called „Socket‟.
 Socket is a point of communication between a server and a client on a
network.
 The java.net.Socket class allows us to create socket objects that help us in
implementing all fundamental socket operations.
 We can perform various networking operations such as sending, reading data
and closing connections.
 Each Socket object that has been created using with java.net.Socket class has
been associated exactly with 1 remote host, for connecting to another
different host, we must create a new socket object.
Prof. Babar Patil R. M. Page 10
Constructors for socket Class : -
1) public Socket(String host, int port) throws UnknownHostException,
IOException.
This method attempts to connect to the specified server at the specified port. If
this constructor does not throw an exception, the connection is successful and
the client is connected to the server.

2) public Socket(InetAddress host, int port) throws IOException


This method is identical to the previous constructor, except that the host is
denoted by an InetAddress object.

3) public Socket(String host, int port, InetAddress localAddress, int localPort)


throws IOException.
Connects to the specified host and port, creating a socket on the local host at
the specified address and port.

4) public Socket(InetAddress host, int port, InetAddress localAddress, int


localPort) throws IOException.
This method is identical to the previous constructor, except that the host is
denoted by an InetAddress object instead of a String.

5) public Socket()
Creates an unconnected socket. Use the connect() method to connect this
socket to a server.

Methods of Socket Class: -


1) public void connect(SocketAddress host, int timeout) throws IOException
This method connects the socket to the specified host. This method is needed
only when you instantiate the Socket using the no-argument constructor.

2) public InetAddress getInetAddress()


This method returns the address of the other computer that this socket is
connected to.

Prof. Babar Patil R. M. Page 11


3) public int getPort()
Returns the port the socket is bound to on the remote machine.

4) public int getLocalPort()


Returns the port the socket is bound to on the local machine.

5) public SocketAddress getRemoteSocketAddress()


Returns the address of the remote socket.

6) public InputStream getInputStream() throws IOException


Returns the input stream of the socket. The input stream is connected to the
output stream of the remote socket.

7) public OutputStream getOutputStream() throws IOException


Returns the output stream of the socket. The output stream is connected to the
input stream of the remote socket.

8) public void close() throws IOException


Closes the socket, which makes this Socket object no longer capable of
connecting again to any server.

How to Create a Client Socket: -

To create a client socket, do the following:


1) Create an object of the Socket class using the server name and port as
parameters.
2) Communicate with the server.
3) Close the socket.

Program 1:-
import java.net.*;
import java.io.*;

Prof. Babar Patil R. M. Page 12


public class WindowDemo
{
public static void main(String args[])
{
try
{
Socket theSocket = new Socket("www.google.com", 80);
System.out.println("Connected to " + theSocket.getInetAddress() on port" +
theSocket.getPort() + " from port theSocket.getLocalPort() + " of "
+ theSocket.getLocalAddress());
> // end try
catch (UnknownHostException e) {
System.err.println("I can't find https://www.google.com");
System.err.println("Could not connect to https://www.google.com");
}
catch (SocketException e) {
}
catch (IOException e)
{
System.err.println(e);
} // end main // end SocketInfo

Output:
Connected to www.google.com/172.217.27.196 on port 88 from port 53771 of
/192.168.1.4

2) ServerSocket Class :-
 Java has a different socket class that must be used for creating server
applications.
 The ServerSocket class is used to create servers that listen for either local or
remote client programs to connect to them on published ports.

Prof. Babar Patil R. M. Page 13


 ServerSockets are quite different from normal Sockets. When we create a
ServerSocket, it will register itself with the system as having an interest in
client connections.
 The constructors for ServerSocket reflect the port number that we wish to
accept connections.
 In Java, the basic life cycle of a server program is:
1) A new ServerSocket is created on a particular port using a ServerSocket()
constructor.
2) The ServerSocket listens for incoming connection attempts on that port using
its accept() method. A ServerSocket operates in a loop that repeatedly accepts
connections. Each pass through the loop invokes the accept() method. The
accept() method returns a Socket object representing the connection between
the remote client and the local server.
3) Depending on the type of server, either the Socket's getInputStream() method,
getOutputStream() method, or both are called to get input and output streams
that communicate with the client.
4) The server and the client interact according to an agreed-upon protocol until it
is time to close the connection. The server the client, or both can close the
connection.
5) The server returns to step 2 and waits for the next connection, if connection not
closed by server.

Constructors of ServerSocket Class:

Sr.No. Method & Description

public ServerSocket(int port) throws IOException


1 Attempts to create a server socket bound to the specified port. An exception
occurs if the port is already bound by another application.

public ServerSocket(int port, int backlog) throws IOException


2 Similar to the previous constructor, the backlog parameter specifies how many
incoming clients to store in a wait queue.

public ServerSocket(int port, int backlog, InetAddress address) throws


IOException
3
Similar to the previous constructor, the InetAddress parameter specifies the local
IP address to bind to. The InetAddress is used for servers that may have multiple
IP addresses, allowing the server to specify which of its IP addresses to accept

Prof. Babar Patil R. M. Page 14


client requests on.

public ServerSocket() throws IOException


4 Creates an unbound server socket. When using this constructor, use the bind()
method when you are ready to bind the server socket.

Following are some of the common methods of the ServerSocket class −

Sr.No. Method & Description

public int getLocalPort()

1 Returns the port that the server socket is listening on. This method is useful if
you passed in 0 as the port number in a constructor and let the server find a port
for you.

public Socket accept() throws IOException


Waits for an incoming client. This method blocks until either a client connects to
2 the server on the specified port or the socket times out, assuming that the time-
out value has been set using the setSoTimeout() method. Otherwise, this method
blocks indefinitely.

public void setSoTimeout(int timeout)


3 Sets the time-out value for how long the server socket waits for a client during
the accept().

public void bind(SocketAddress host, int backlog)

4 Binds the socket to the specified server and port in the SocketAddress object.
Use this method if you have instantiated the ServerSocket using the no-
argument constructor.

When the ServerSocket invokes accept(), the method does not return until a client
connects. After a client does connect, the ServerSocket creates a new Socket on an
unspecified port and returns a reference to this new Socket. A TCP connection now
exists between the client and the server, and communication can begin.

Program 2: - TCP/IP communication between client and server. Sending a single


message from server to client.

Prof. Babar Patil R. M. Page 15


Server Side Program using ServerSocket class :-

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server1 {

public static void main(String[] args) throws IOException {


// TODO Auto-generated method stub
ServerSocket ss = new ServerSocket(9999);
System.out.println("Server Started, Wait for client Connectio...");
Socket s1 = ss.accept();

System.out.println("Client Connected");

OutputStream out = s1.getOutputStream();

DataOutputStream os = new DataOutputStream(out);


os.writeUTF("Hi There");

os.close();
out.close();
s1.close();

Client Side Program using ServerSocket class :-

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.*;

public class Client {

public static void main(String[] args) throws IOException{


// TODO Auto-generated method stub
Socket s = new Socket("localhost", 9999);
InputStream in = s.getInputStream();
DataInputStream ds = new DataInputStream(in);

Prof. Babar Patil R. M. Page 16


String st = new String(ds.readUTF());
System.out.println(st);
ds.close();
in.close();
s.close();

 URL Class :-
 The URL class is the gateway to any of the resources available on the
internet.
 A Class URL represents a Uniform Resource Locator, which is a pointer to a
“resource” on the World Wide Web.
 A resource can point to a simple file or directory, or it can refer to a more
complicated object, such as a query to a database or to a search engine.

Constructors of URL Class :-

1) URL (String spec)

Creates a URL object from the string representation.

2) URL (String protocol, String host, int port, String file)

Create URL object from the specified protocol, host, port number and
file.

3) URL (String protocol, String host, String file)

Create URL object from the specified protocol, host name and file name.

Prof. Babar Patil R. M. Page 17


Commonly used methods of Java URL class
The java.net.URL class provides many methods. The important methods of

Method Description

public String getProtocol() it returns the protocol of the URL.

public String getHost() it returns the host name of the URL.

public String getPort() it returns the Port Number of the URL.

public String getFile() it returns the file name of the URL.

public String getAuthority() it returns the authority of the URL.

public String toString() it returns the string representation of


the URL.

public String getQuery() it returns the query string of the URL.

public String getDefaultPort() it returns the default port of the URL.

public URLConnection It returns the instance of


openConnection() URLConnection i.e. associated with
this URL.

public boolean equals(Object it compares the URL with the given


obj) object.

public Object getContent() it returns the content of the URL.

public String getRef() it returns the anchor or reference of the


URL.

public URI toURI() it returns a URI of the URL.

Program 1: URL class


import java.net.*;

public class URLDemo{


public static void main(String[]

Prof. Babar Patil R. M. Page 18


args){ try{
URL url=new URL("http://www.yahoo.com:80/index");

System.out.println("Protocol: "+url.getProtocol());
System.out.println("Host Name: "+url.getPath());
System.out.println("Host Name: "+url.getHost());
System.out.println("Port Number: "+url.getPort());
System.out.println("File Name: "+url.getFile());

}catch(Exception e){System.out.println(e);}
}
}

 URLConnection Class :-

 URLConnection is an abstract class that represents an active connection of a


resource specified by a URL.
 The URLConnection class has following two different but related purposes.
1. First, it provides more control over the interaction with a server (especially an
HTTP server) than the URL class. With an URLConnection, we can inspect
the header sent by the server and respond accordingly. We can set the header
fields used in the client request. We can use URLConnection to download
binary files.

2. An URLConnection lets us send data back to a web server with POST or PUT
and use other request methods.
 The biggest differences between the URL and URLConnection classes are:
1. URLConnection provides access to the HTTP header.
2. URLConnection can configure the request parameters sent to the server.
3. URLConnection can write data to the server as well as read data from theserver.

Constructors of URLConnection Class:


1) URLConnection(URL url)
Construct a URL connection to the specified URL. A connection to the
the object referenced by the URL is not created.

Prof. Babar Patil R. M. Page 19


Major methods of the URLConnection class:-

Method Description

void connect() It opens a communications link to the resource


referenced by this URL, if such a connection has not
already been established.

int getConnectionTimeout() It returns setting for connect timeout.

Object getContent() It retrieves the contents of the URL connection.

int getContentLength() It returns the value of the content-length header field.

String getContentType() It returns the value of the date header field.

long getDate() It returns the value of the date header field.

long getExpiration() It returns the value of the expires header files.

String getHeaderField(int n) It returns the value of nth header field

String getHeaderField(String It returns the value of the named header field.


name)

InputStream getInputStream() It returns an input stream that reads from the open
condition.

long getLastModified() It returns the value of the last-modified header field.

OutputStream It returns an output stream that writes to the connection.


getOutputStream()

Permission getPermission() It returns a permission object representing the


permission necessary to make the connection
represented by the object.

int getReadTimeout() It returns setting for read timeout.

URL getURL() It returns the value of the URLConnection's URL field.

Program 1: URLConnection class


package ac;

import java.io.IOException;
import java.io.InputStream;
import java.net.*;

Prof. Babar Patil R. M. Page 20


public class abc {

public static void main(String[] args) throws IOException {


// TODO Auto-generated method stub
URL u = new URL("https://www.tutorialride.com/core-
java/urlconnection-class-in-java.htm");

URLConnection c = u.openConnection();
InputStream s = c.getInputStream();

System.out.println("getURL : " + c.getURL());


System.out.println("GetContentLength : " + c.getContentLength());
System.out.println("GetContentType : " + c.getContentType());
System.out.println("GetDate : " + c.getDate());
System.out.println("Last Modified : " + c.getLastModified());

System.out.println("GetContent : " + c.getContent());

int i;
while ((i = s.read()) != -1)
System.out.print((char)i);

Prof. Babar Patil R. M. Page 21

You might also like