FTP java ÉÏ´« ÏÂÔØ
package com.ftp;
import com.enterprisedt.net.ftp.FTPClient;
import com.enterprisedt.net.ftp.FTPFile;
import com.enterprisedt.net.ftp.FTPMessageCollector;
import com.enterprisedt.net.ftp.FTPTransferType;
import com.enterprisedt.net.ftp.FTPConnectMode;
import com.enterprisedt.util.debug.Level;
import com.enterprisedt.util.debug.Logger;
import java.io.File;
import java.util.List;
/**
*
*/
public class FtpUtil {
/** ÅжÏÎļþ¼ÐÊÇ·ñ´æÔÚ£¬ÕâÖÖ·½Ê½²»ÊǺÜ×¼ */
public static boolean isDirExist(String dirname, String[] files) {
for (int i = 0; i < files.length; i++) {
if (files[i].indexOf("<DIR>") > -1 && files[i].indexOf(dirname) > -1) {
return true;
}
}
return false;
}
public void upDownFile() {
String host = "10.163.7.15";
String user = "cxl";
String password = "1";
/** ¶¨ÒåFTPClient±ãÀû */
FTPClient ftp = null;
try {
/** ´´½¨FTPClient */
ftp = new FTPClient();
/** Á¬½Ó·þÎñÆ÷ */
ftp.setRemoteHost(host);
ftp.connect();
/** 怫 */
ftp.login(user, password);
/** ÒÔ²¨¶¯Ä£Ê½Á¬½Ó */
ftp.setConnectMode(FTPConnectMode.PASV);
/**
* ASCII·½Ê½£ºÖ»ÄÜ´«ÊäһЩÈçtxtÎı¾Îļþ£¬ zip¡¢jpgµÈÎļþÐèҪʹÓÃBINARY·½Ê½
* */
// ftp.setType(FTPTransferType.ASCII);
ftp.setType(FTPTransferType.BINARY);
/**
* Çл»µ½Ö÷Ŀ¼£¬²¢Ã¶¾ÙÖ÷Ŀ¼µÄËùÓÐÎļþ¼°Îļþ¼Ð °üÀ¨ÈÕÆÚ¡¢Îļþ´óСµÈÏêϸÐÅÏ¢ files = ftp.dir(".")£¬ÔòÖ»ÓÐÎļþÃû
*/
String[] files = ftp.dir(".", true);
for (int i = 0; i < files.length; i++)
System.out.println(files[i]);
/** ÏÂÔØinfoÎļþ¼ÐϵÄËùÓÐÎļþµ½ d:\temp Ŀ¼Ï */
Str
Ïà¹ØÎĵµ£º
×î½ü¹«Ë¾Åöµ½ÐèÒªÓÃͼ±íµÄÐÎʽÏÔʾһЩÊý¾Ý£¬ÎҾͿªÊ¼µ½ÍøÉϲéѯ£¬²éµ½ÁËjfreechartºÍamcharts,ÕâÁ½ÕßÎÒ¶¼ÊµÏÖ¹ýÁË£¬jfreechart×îºóÉú³ÉͼƬ£¬µ«ÊÇͼƬЧ¹û²»ÊÇÎÒÏëÒªµÄ£¬È»ºóÓÖÑо¿amcharts ËüµÄЧ¹ûȷʵºÜºÃ£¬¶øÇÒ¹Ù·½ÍøÕ¾ÉÏ»¹ÓкÃЩÀý×ӿɹ©ÏÂÔØ£¬ÍøÖ·ÊÇ:www.amcharts.com
£¨ÏëÒªÍê³ÉÒ»¸öamchartsͼÐÎÐèÒªswfobjects. ......
java(Web)ÖÐÏà¶Ô·¾¶£¬¾ø¶Ô·¾¶ÎÊÌâ×ܽá
Ç°ÑÔ£º
Ç°Ò»¶Îʱ¼ä£¬ÓÉÓÚÔÚ´¦ÀíWebÓ¦ÓÃϵÄÎļþ´´½¨ÓëÒƶ¯µÈ£¬Òò´ËÉæ¼°µ½ºÜ¶à¹ØÓÚjava
ÖÐÏà¶Ô·¾¶£¬¾ø¶Ô·¾¶µÈÎÊÌ⡣ͬʱ£¬¶ÔÓÚWebÓ¦ÓÃÖеÄÏà¶Ô·¾¶£¬¾ø¶Ô·¾¶£¬ÒÔ¼°Java.io.File
ÀàѧϰÁËһϡ£Ò²ÕÒÁËһЩ×ÊÁÏ¡£Ï£Íû´ó¼ÒÓöµ½ÀàËƵÄÎÊÌ⣬¿ÉÒÔ¸üÓÐЧµÄ½â¾ö¡£
========= ......
InputStream stream;
Properties prop = new Properties();// ÊôÐÔ¼¯ºÏ¶ÔÏó
stream = getClass().getResourceAsStream("NcJdbc.properties");
prop.load(stream);
stream.close();// ¹Ø±ÕÁ÷
String databaseName=prop.getProperty("jdbc.databaseName");
InputStream stream;
Properties prop = new Properties(); ......
ÎļþÉÏ´«·½·¨£¨Ò»´ÎÉÏ´«Ò»¸öÎļþ£¬¶à¸öÎļþµÄ»°£¬Çëдѻ·µ÷Óã©
Upload.uploadFile(theFile, filePath)
˵Ã÷£º
theFile£ºÀàÐÍÊÇFormFile
filePath£ºactionÖз¾¶»ñÈ¡·½·¨ this.getServlet().getServletContext().getRealPath("/")
µ÷Óô˷½·¨·µ»ØÎļþÉÏ´«ºóµÄ·¾¶Ãû
ÉÏ´«¶à¸öÎļþʱ£¬ÇëÉèÖÃÿ¸öÎ ......
תÔصØÖ·£ºhttp://www.javaeye.com/topic/40489
´ÓJDK 1.4¿ªÊ¼£¬JavaµÄ±ê×¼¿âÖоͰüº¬ÁËNIO£¬¼´ËùνµÄ“New IO”¡£ÆäÖÐ×îÖØÒªµÄ¹¦ÄܾÍÊÇÌṩÁË“·Ç×èÈû”µÄIO£¬µ±È»°üÀ¨ÁËSocket¡£NonBlockingµÄIO¾ÍÊǶÔselect(Unixƽ̨ÏÂ)ÒÔ¼° WaitForMultipleObjects(Windowsƽ̨)µÄ·â×°£¬ÌṩÁ˸ßÐÔÄÜ¡¢Ò×ÉìËõµÄ·þÎ ......