Import java. AWT. event. actionevent;
Import java. AWT. event. actionlistener;
Import java. Io. datainputstream;
Import java. Io. fileinputstream;
Import java. Io. fileoutputstream;
Import java. Io. inputstream;
Import java. Io. outputstream;
Import java.net. datagrampacket;
Import java.net. datagramsocket;
Import java.net. serversocket;
Import java.net. Socket;
Import javax. Swing. jbutton;
Import javax. Swing. jfilechooser;
Import javax. Swing. jframe;
Public class ipserver {
/**
* @ Param ARGs
*/
Jbutton save = new jbutton ("save ");
Serversocket SS;
Socket S;
Fileoutputstream Fos;
Fileinputstream FCM;
Outputstream OS;
Datainputstream IP;
String filename;
Byte [] Buf = new byte [1, 1024];
Public static void main (string [] ARGs ){
// Todo auto-generated method stub
New ipserver (). Start ();
}
Public ipserver (){
}
Public void start ()
{
Try {
Byte B [] = new byte [1024];
System. Out. Print ("waiting for connection... \ n ");
Ss = new serversocket (8888 );
S = ss. Accept ();
System. Out. Print ("link ...... \ n ");
IP = new datainputstream (S. getinputstream ());
Fos = new fileoutputstream ("D:/1.jpg ");
Int C = 0;
Int I = 0;
While (C = IP. Read (B, 0, B. Length)> 0)
{
I = C + I;
FOS. Write (B, 0, C );
FOS. Flush ();
}
System. Out. Print ("Finish \ n" + I );
} Catch (exception E)
{
E. printstacktrace ();
}
}
}