Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java FTP²Ù×÷

 ¼òµ¥µÄдÁ˸öjava¶ÔftpµÄ²Ù×÷
ÓõÄÊÇcommons-net.jar°ü
FTPProxy.java
public class FTPProxy{
public FTPProxy()
{
super();
ftpClient = new FTPClient();
}
public FTPProxy(FTPBean entity)
{
this();
this.entity = entity;
}
private FTPBean entity;
private FTPClient ftpClient;
public void connection()
{
try
{
ftpClient.connect(entity.getServerIP());
ftpClient.login(entity.getUser(), entity.getPassword());
} catch (SocketException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
}
public void download()
{
FileOutputStream fos = null;
try
{
String remoteFile = entity.getSrcFile();
String remoteFileName = "";
if (0 == remoteFile.lastIndexOf("/"))
{
remoteFileName = remoteFile.substring(remoteFile
.lastIndexOf("/") + 1);
} else if (0 < remoteFile.lastIndexOf("/"))
{
remoteFileName = remoteFile.substring(remoteFile
.lastIndexOf("/") + 1);
String path = remoteFile.substring(0, remoteFile
.lastIndexOf("/"));
ftpClient.changeWorkingDirectory(path);
} else
{
remoteFileName = remoteFile;
}
fos = new FileOutputStream(entity.getTargetFile());
ftpClient.setBufferSize(1024 * 8);
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
ftpClient.retrieveFile(remoteFileName, fos);
} catch (IOException e)
{
e.printStackTrace();
} finally
{
try
{
fos.close();
ftpClient.disconnect();
} catch (IOException e)
{
e.printStackTrace();
}
}
}
public void upload()
{
FileInputStream fis = null;
try
{
File srcFile = new File(entity.getSrcFile());
fis = new FileInputStream(srcFile);
ftpClient.setBufferSize(1024 * 8);
ftpClient.setControlEncoding("GBK");
String ftpPath = entity.getFtpPath();
if(null!=ftpPath&&!"".equals(ftpPath))
{
ftpClient.makeDirectory(ftpPath);
ftpClient.changeWo


Ïà¹ØÎĵµ£º

javaÖÐÏßÐÔ±í£¬Á´±í£¬¹þÏ£±íÊdz£ÓõÄÊý¾Ý½á¹¹

ÏßÐÔ±í£¬Á´±í£¬¹þÏ£±íÊdz£ÓõÄÊý¾Ý½á¹¹£¬ÔÚ½øÐÐJava¿ª·¢Ê±£¬JDKÒѾ­ÎªÎÒÃÇÌṩÁËһϵÁÐÏàÓ¦µÄÀàÀ´ÊµÏÖ»ù±¾µÄÊý¾Ý½á¹¹¡£ÕâЩÀà¾ùÔÚjava.util°üÖС£±¾ÎÄÊÔͼͨ¹ý¼òµ¥µÄÃèÊö£¬Ïò¶ÁÕß²ûÊö¸÷¸öÀàµÄ×÷ÓÃÒÔ¼°ÈçºÎÕýȷʹÓÃÕâЩÀà¡£    
   
  Collection  
  ©ÀList& ......

¶þ¡¢Ð½¨Ò»¸öjava´°¿Ú

1¡¢Ê×ÏÈ´ó¼Ò×îºÃÈ¥ÏÂÔØÒ»¸ödesigner µÄeclipse ²å¼þ
2¡¢È»ºó·ÅÈëeclipse °²×°Ä¿Â¼ÏµÄpluginĿ¼ÏÂ
3¡¢ÖØÐÂÆô¶¯eclipse
4  н¨Ò»¸öjava swing project
5, н¨Ò»¸öwindow£¬È»ºóµãÔËÐУ¬¾Í»á³öÏÖÒ»¸ö×î¼òµ¥µÄ´°¿Ú¡£
µ±È»£¬ÄãÒ²¿ÉÒÔн¨Ò»¸öclass Window£¬È»ºóÊäÈëÈçÏ´úÂë
import java.awt.Dimension;
import ......

°Ë Ò»¸öJAVA°¸Àý

   ¼ÙÉèÐèÇó(ÈçÓÐÀ×ͬ£¬´¿ÊôÇɺÏ)£º
     ÓÐÒ»¸öÈ«¹úÐԵĴóÆóÒµ£¬ÔÚÈ«¹ú¸÷µØÐèÒª²¿ÊðÉÏǧ̨¿Í»§»ú£¬ÕâЩ¿Í»§»úÐèҪʵʱÓë·þÎñÆ÷½»»¥£¬½øÐÐÊý¾Ý´¦Àí¡£ÊµÊ±ÐÔÒªÇó¸ß£¬°²È«ÐԸߣ¬ÒªÇóÖ§³ÖÊÂÎñ£¬ÒÔ¼°²»ÖжϷþÎñ¡£
   
Ó²¼þ²¿Êð£º
  1¡¢ 3000̨¿Í»§»ú
  2¡¢ 10̨· ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ