import java.io.*; import java.net.*; class JavaFtpClient { public static void main(String[] args) throws IOException { int MAXSIZE = 4096; // bytes Socket t = new Socket(args[0], 8189); String fName = args[1]; DataInputStream is = new DataInputStream(t.getInputStream()); PrintStream out = new PrintStream(t.getOutputStream()); // first, send file name over to the server out.println(fName); fName += ".new"; File f = new File(fName); FileOutputStream outFile = new FileOutputStream(f); // now receiving the file boolean more = true; byte[] data = new byte[MAXSIZE]; int bytesRead = 0; while (more) { bytesRead = is.read(data); if (bytesRead > 0) { System.out.println("bytes read : "+bytesRead); outFile.write(data,0,bytesRead); } else more = false; } // while outFile.close(); is.close(); out.close(); } // main }