import java.io.*;
import java.net.*;
class client
{
public static void main(String[] args) throws Exception
{
Socket s = new Socket("192.168.1.100",3000);
OutputStream out = s.getOutputStream();
//BufferedOutputStream bo = new BufferedOutputStream(out);
byte[] b = new byte[1024];
BufferedInputStream bi = new BufferedInputStream(new FileInputStream("d:\\1.jpg"));
int len = 0;
System.out.println("Hello World!");
while ((len = bi.read(b) ) != -1)
{
out.write( b, 0, len);
}
}
}
class sever
{
public static void main(String[] args) throws Exception
{
ServerSocket s = new ServerSocket(3000);
Socket ss = s.accept();
InputStream in = ss.getInputStream();
BufferedOutputStream bo = new BufferedOutputStream(new FileOutputStream("d:\\2.jpg"));
byte[] b = new byte[1024];
// BufferedInputStream bi = new BufferedInputStream(new FileInputStream("c:\\1.jpg"));
int len = 0;
while ((len = in.read(b) ) != -1)
{
bo.write( b, 0, len);
bo.flush();
}
System.out.println("Hello World!");
}
}
out.write( b, 0, len);
|
|