package test;
import java.io.*;
import java.net.*;
public class HelloWordFTP {
private static final int CTRLPORT = 21;
private static Socket ctrlSocket;
private static PrintWriter ctrlOutput;
private static BufferedReader ctrlInput;
private static byte[] localHostAddress;
public static void main(String[] args) {
try {
String host = "10.36.254.27 ";
String loginName = "eptftp ";
String password = "ept ";
String dirName = "/Inetpub/ftproot/userhome/Localuser/eptftp ";
String fileName = "C:\\temp\\Seikyusyo.txt ";
ctrlSocket = new Socket(host, CTRLPORT);
System.out.println( "dd ");
localHostAddress = ctrlSocket.getLocalAddress().getAddress();
ctrlOutput = new PrintWriter(ctrlSocket.getOutputStream());
ctrlInput = new
BufferedReader(new InputStreamReader(ctrlSocket.getInputStream()));
ctrlOutput.println( "USER " + loginName);
ctrlOutput.flush();
ctrlOutput.println( "PASS " + password);
ctrlOutput.flush();
ctrlOutput.println( "CWD " + dirName);
ctrlOutput.flush();
ctrlOutput.println( "TYPE I ");
ctrlOutput.flush();
System.out.println( "write begin ");
FileInputStream fis = new FileInputStream(fileName);
Socket dataSocket = dataConnection( "STOR " + fileName);
OutputStream outstr = dataSocket.getOutputStream();
int n;
byte[] buff = new byte[1024];
while ((n = fis.read(buff)) > 0) {
outstr.write(buff,0,n);