package ignisftpv20; import java.io.*; import java.net.*; import javax.swing.JOptionPane; public class FTPServerReceiver implements Runnable{ FTPServer ftpServer; Socket thesocket; Byte bt; ObjectInputStream input; FileOutputStream fout; String directoryName = "C:/Documents and Settings/My User/Desktop/Complete Download"; public FTPServerReceiver(FTPServer ftpServer, Socket s){ this.ftpServer = ftpServer; this.thesocket = s; new Thread( this ).start(); } //read and write file public void run(){ try{ while(true){ JOptionPane.showMessageDialog(null, "Server Receiver says: Incoming in progress ..."); input = new ObjectInputStream(thesocket.getInputStream()); byte[] buffer = new byte[1024]; int bytes = 0; input.read(buffer,0,bytes); File f = new File(directoryName,"file1"); fout = new FileOutputStream(f); fout.write(input.read(buffer,0,bytes)); } }catch(Exception e){e.printStackTrace();} //JOptionPane.showMessageDialog(null, "Reception completed ..."); } }