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

javaʵÏÖµÄFTPÉÏ´«ÏÂÔØ¿Í»§¶Ë

org.apache.commons.net.ftp.*ÖеÄFTPClientÀàʵÏÖµÄFTPÉÏ´«ÏÂÔع¦ÄÜ£º
Ðèµ¼ÈëApacheµÄcommos-netµÄjar°ü£¬Èôµ¼ÈëµÄÊÇ1.4°æ±¾µÄ°ü£¬ÔòFTPFile[] fileList = ftpClient.listFiles()µÄÖ´Ðйý³ÌÖпÉÄܻᱨ´í£¬´Ëʱ¸ü»»µ¼Èë2.0°æ±¾µÄjar°ü£¬ÎÊÌâ¼´¿É½â¾ö¡£
´úÂëÈçÏ£º
package com.java.ftp;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.commons.net.ftp.*;
public class FtpUtil {
private FTPClient ftpClient = new FTPClient();
/**
* Á¬½Óµ½FTP·þÎñÆ÷
*
* @param host
* FTPµØÖ·
* @param port
* ¶Ë¿ÚºÅ
* @param username
* ̞
* @param password
* ÃÜÂë
*/
public boolean ftpConnect(String host, int port, String username,
String password) {
try {
ftpClient.connect(host, port);
ftpClient.setControlEncoding("GBK");
int reply = ftpClient.getReplyCode();
if (FTPReply.isPositiveCompletion(reply)) {
if (ftpClient.login(username, password)) {
System.out.println("Successful login!");
return true;
} else {
System.out.println("fail to login!");
}
}
} catch (Exception e) {
System.out.println("Failure connection!");
e.printStackTrace();
}
return false;
}
//´Ó±¾µØÉÏ´«µ¥¸öÎļþ£¬localName£º±¾µØÎļþ·¾¶°üº¬ÎļþÃû£¬ftpFile£ºËùÒª·ÅÓÚftpµÄÎļþ¼Ð£¬newName£ºÖØÃüÃû
public void ftpUpload(String localName, String ftpFile, String newName) {
File srcFile = new File(localName);
FileInputStream fis = null;
try {
fis = new FileInputStream(srcFile);
//¸Ä±ä¹¤×÷Ŀ¼µ½ËùÐèÒªµÄ·¾¶ÏÂ
ftpClient.changeWorkingDirectory(ftpFile);
ftpClient.setBufferSize(1024);
ftpClient.setControlEncoding("GBK");
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
ftpClient.storeFile(newName, fis);
} catch (Exception e) {
System.out.println("Failed to upload!");
e.printStackTrace


Ïà¹ØÎĵµ£º

[ת]ÔÙÂÛJavaδÀ´Ö®Â·

2006ÄêÎÒÔø¾­Ð´¹ýһƪÌÖÂÛJavaδÀ´µÄÎÄÕ£¬ÔÚÄÇƪÎÄÕÂÖÐÎÒÌÖÂÛÁË¿ªÔ´¡¢JavaÔÚÏû·Ñµç×ÓÉ豸ÖеÄʹÓã¬ÏÖÔÚÔÚËùÓÐÀàÐ͵ÄÒƶ¯É豸ÉÏJavaµÄÓ¦ÓÃÕýÔÚÖð²½ÉÏÉý¡£¶ÔSun±»ÊÕ¹ºÒ»Ê£¬ÒÔ¼°JavaÓëOracle²úÆ·¼¯³ÉÎÒûʲôºÃÔ¤²âµÄ£¬Ò²Ã»Ê²Ã´ºÃµÄ½¨Ò飬ÎÒÖ»µ£ÐÄJavaµÄδÀ´»á×ßÏòºÎ·½?ÔÚÕâƪÎÄÕÂÖÐÎÒÖØÐÂÉóÊÓÁËOracleÊÕ¹ºSunºóJavaµÄδÀ´Ö ......

JAVAÖÐÓÃÓÚ´¦Àí×Ö·û´®µÄ¡°ÈýÐֵܡ±

     JAVAÖÐÓÃÓÚ´¦Àí×Ö·û´®³£ÓõÄÓÐÈý¸öÀࣺjava.lang.String¡¢java.lang.StringBuffer¡¢java.lang.StringBuilder£¬ÕâÈýÕߵĹ²Í¬Ö®´¦¶¼ÊÇfinalÀ࣬²»ÔÊÐí±»¼Ì³Ð£¬ÕâÖ÷ÒªÊÇ´ÓÐÔÄܺͰ²È«ÐÔÉÏ¿¼Âǵģ¬ÒòΪÕ⼸¸öÀ඼ÊǾ­³£±»Ê¹ÓÃ×ŵģ¬ÇÒ¿¼Âǵ½·ÀÖ¹ÆäÖеIJÎÊý±»ÐÞ¸ÄÓ°Ïìµ½ÆäËüµÄÓ¦Óá£StringBufferÓëStrin ......

JAVAÖеÄÒÀÀµµ¹Ô­Ôò

JAVAÖеÄÒÀÀµµ¹Ô­Ôò
ÃÀ¹ú·¨ÂÉÓÐÒ»Ìõ×î»ù±¾µÄ×¼Ôò¾ÍÊÇ“ÈËÈËƽµÈ”£¬ÎÒÃDz»È¥¹ÜËüÊǾ­¹ýʲôÑùµÄ¶·Õù¡¢Ê²Ã´ÑùµÄÁ÷ѪÎþÉü»»À´µÄ£¬Ö»°ÑËüÀí½âΪһ¸öJAVA·½·¨£¬¸Ã·½·¨¶¨ÒåÈçÏ£º
    public final boolean ÈËÈËƽµÈ(ÈË1£¬ÈË2){
       return true;
  &n ......

Java³ÌÐòÔ±ÐèÒªÁ˽âµÄ¼¸¸ö¿ªÔ´Ð­Òé

½ñÌ칤×÷µÄÈÎÎñҪдһЩ¸ú¿ªÔ´Ð­ÒéÏà¹ØµÄÔ¼¶¨ËµÃ÷£¬ËùÒÔÔÚÍøÉÏËÑË÷ÁËһЩ×ÊÁÏÒÔ¹©²Î¿¼£¬ÏÂÃæÁгöÁ˼¸¸ö±È½Ï³£¼ûµÄ¿ªÔ´Ð­Ò飬Èç¹ûÏëÒªÁ˽âÆäËûµÄЭÒé
ºÍÏêϸÁ˽âÕâЩЭÒ飬ÎÒ¸öÈËÍƼöÕâ¸öÍøÖ·£ºhttp://www.opensource.org/licenses/
¡¡¡¡Mozilla Public License
¡¡¡¡MPL License£¬ÔÊÐíÃâ·ÑÖØ·¢²¼¡¢Ãâ·ÑÐ޸ģ¬µ«ÒªÇóÐ޸ĺó ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ