今天在下载频道找到的
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;import sun.net.TelnetOutputStream;
import sun.net.TelnetInputStream;
import sun.net.ftp.FtpClient;
public class ftptest 
{
FtpClient ftpClient;
private String localfilename;
private String remotefilename;
static String a = new String();
static int b;
static String c = new String();
static String d = new String();
static String e = new String();

File aFile = new File("e:\\12\\"); String[] fileList = aFile.list();

public void connectServer(String ip, int port,String user, String password,String path) 
{
try {
ftpClient = new FtpClient();
ftpClient.openServer(ip,port);
ftpClient.login(user, password);
System.out.println("login success!");
if (path.length() != 0) 
{
ftpClient.cd(path);
}
ftpClient.binary();
} catch (IOException ex) {
System.out.println("not login");
System.out.println(ex);
}
}

public void closeConnect() 
{
try {
ftpClient.closeServer();
System.out.println("disconnect success");

catch (IOException ex) 
{
System.out.println("not disconnect");
System.out.println(ex);
}
} public void upload() {

//this.localfilename = "e://12//bb.txt";
//this.remotefilename = "bb.txt";
for(int i = 0; i<fileList.length;i++)
{
try {
TelnetOutputStream os = ftpClient.put(fileList[i]);
java.io.File file_in = new java.io.File("e://12//" + fileList[i]);
FileInputStream is = new FileInputStream(file_in);
byte[] bytes = new byte[1024];
int c;
while ((c = is.read(bytes)) != -1) {
os.write(bytes, 0, c);
}
System.out.println("upload success");
is.close();
os.close();
} catch (IOException ex) {
System.out.println("not upload");
System.out.println(ex);
}
}
} public static void main(String[] args) throws IOException
{
BufferedReader reader = null;
PrintWriter writer = null;
try
{
reader = new BufferedReader(new FileReader("d:\\test\\test.ini"));
// writer = new PrintWriter(new FileWriter(args[1]));
String line;
List list = new ArrayList();


while ((line = reader.readLine()) != null)
{
// writer.println(line);
list.add(line);

}
String str[] = new String[list.size()];
list.toArray(str); 

//System.out.println(str[1]);
a = str[0];
b = Integer.parseInt(str[1]);
c = str[2];
d = str[3];
e = str[4]; }
catch(Exception e)
{
System.out.println(e.toString());
}

finally{
if (reader != null) reader.close();
if (writer != null) writer.close();
}


ftptest fu = new ftptest();
fu.connectServer(a,b, c, d, e);

// fu.upload();
fu.closeConnect();
}

}