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

ÓÃJavaʵÏÖFTP·þÎñÆ÷

FTP(File Transfer Protocol Îļþ´«ÊäЭÒé)ÊÇInternet ÉÏÓÃÀ´´«ËÍÎļþµÄЭÒé¡£ÔÚInternetÉÏͨ¹ýFTP ·þÎñÆ÷¿ÉÒÔ½øÐÐÎļþµÄÉÏ´«(Upload)»òÏÂÔØ(Download)¡£FTPÊÇʵʱÁª»ú·þÎñ£¬ÔÚʹÓÃËü֮ǰ±ØÐëÊǾßÓи÷þÎñµÄÒ»¸öÓû§(Óû§ÃûºÍ¿ÚÁî)£¬¹¤×÷ʱ¿Í»§¶Ë±ØÐëÏȵǼµ½×÷Ϊ·þÎñÆ÷Ò»·½µÄ¼ÆËã»úÉÏ£¬Óû§µÇ¼ºó¿ÉÒÔ½øÐÐÎļþËÑË÷ºÍÎļþ´«Ë͵ÈÓйزÙ×÷£¬Èç¸Ä±äµ±Ç°¹¤×÷Ŀ¼¡¢ÁÐÎļþĿ¼¡¢ÉèÖô«Êä²ÎÊý¼°´«ËÍÎļþµÈ¡£Ê¹ÓÃFTP¿ÉÒÔ´«ËÍËùÓÐÀàÐ͵ÄÎļþ£¬ÈçÎı¾Îļþ¡¢¶þ½øÖÆ¿ÉÖ´ÐÐÎļþ¡¢Í¼ÏóÎļþ¡¢ÉùÒôÎļþºÍÊý¾ÝѹËõÎļþµÈ¡£
¡¡¡¡FTP ÃüÁî
¡¡¡¡FTP µÄÖ÷Òª²Ù×÷¶¼ÊÇ»ùÓÚ¸÷ÖÖÃüÁî»ù´¡Ö®Éϵġ£³£ÓõÄÃüÁîÓУº
¡¡¡¡¡ô ÉèÖô«Êäģʽ£¬Ëü°üÀ¨ASC¢ò(Îı¾) ºÍBINARY ¶þ½øÖÆģʽ;
¡¡¡¡¡ô Ŀ¼²Ù×÷£¬¸Ä±ä»òÏÔʾԶ³Ì¼ÆËã»úµÄµ±Ç°Ä¿Â¼(cd¡¢dir/ls ÃüÁî);
¡¡¡¡¡ô Á¬½Ó²Ù×÷£¬openÃüÁîÓÃÓÚ½¨Á¢Í¬Ô¶³Ì¼ÆËã»úµÄÁ¬½Ó£»closeÃüÁîÓÃÓڹرÕÁ¬½Ó;
¡¡¡¡¡ô ·¢ËͲÙ×÷£¬putÃüÁîÓÃÓÚ´«ËÍÎļþµ½Ô¶³Ì¼ÆËã»ú£»mput ÃüÁîÓÃÓÚ´«ËͶà¸öÎļþµ½Ô¶³Ì¼ÆËã»ú;
¡¡¡¡¡ô »ñÈ¡²Ù×÷£¬getÃüÁîÓÃÓÚ½ÓÊÕÒ»¸öÎļþ£»mgetÃüÁîÓÃÓÚ½ÓÊÕ¶à¸öÎļþ¡£
¡¡¡¡±à³Ì˼·
¡¡¡¡¸ù¾ÝFTP µÄ¹¤×÷Ô­Àí£¬ÔÚÖ÷º¯ÊýÖн¨Á¢Ò»¸ö·þÎñÆ÷Ì×½Ó×ֶ˿ڣ¬µÈ´ý¿Í»§¶ËÇëÇó£¬Ò»µ©¿Í»§¶ËÇëÇó±»½ÓÊÜ£¬·þÎñÆ÷³ÌÐò¾Í½¨Á¢Ò»¸ö·þÎñÆ÷·ÖỊ̈߳¬´¦Àí¿Í»§¶ËµÄÃüÁî¡£Èç¹û¿Í»§¶ËÐèÒªºÍ·þÎñÆ÷¶Ë½øÐÐÎļþµÄ´«Ê䣬Ôò½¨Á¢Ò»¸öеÄÌ×½Ó×ÖÁ¬½ÓÀ´Íê³ÉÎļþµÄ²Ù×÷¡£
¡¡¡¡±à³Ì¼¼ÇÉ˵Ã÷
¡¡¡¡1.Ö÷º¯ÊýÉè¼Æ
¡¡¡¡ÔÚÖ÷º¯ÊýÖУ¬Íê³É·þÎñÆ÷¶Ë¿ÚµÄÕìÌýºÍ·þÎñÏ̵߳Ĵ´½¨¡£ÎÒÃÇÀûÓÃÒ»¸ö¾²Ì¬×Ö·û´®±äÁ¿initDir À´±£´æ·þÎñÆ÷Ïß³ÌÔËÐÐʱËùÔڵŤ×÷Ŀ¼¡£·þÎñÆ÷µÄ³õʼ¹¤×÷Ŀ¼ÊÇÓɳÌÐòÔËÐÐʱÓû§ÊäÈëµÄ£¬È±Ê¡ÎªCÅ̵ĸùĿ¼¡£
¡¡¡¡¾ßÌåµÄ´úÂëÈçÏ£º
public class ftpServer extends Thread{
private Socket socketClient;
private int counter;
private static String initDir;
public static void main(String[] args){
if(args.length != 0) {
initDir = args[0];
}else{ initDir = "c:";}
int i = 1;
try{
System.out.println("ftp server started!");
//¼àÌý21ºÅ¶Ë¿Ú
ServerSocket s = new ServerSocket(21);
for(;;){
//½ÓÊÜ¿Í»§¶ËÇëÇó
Socket incoming = s.accept();
//´´½¨·þÎñÏß³Ì
new ftpServer(incoming,i).start();
i++;
}
}catch(Exception e){}
}
2. Ïß³ÌÀàµÄÉè¼Æ
¡¡¡¡Ïß³ÌÀàµÄÖ÷ÒªÉè¼Æ¶¼ÊÇÔÚrun()·½·¨ÖÐʵÏÖ¡£ÓÃrun()·½·¨µÃµ½


Ïà¹ØÎĵµ£º

·ÖÀàÅÅÐò·½·¨——ÉÏÒÆÏÂÒƲÙ×÷£¨Java°æ£©

 ×î½üÏîÄ¿ÖÐÓöµ½ÁËÉÏÒÆÏÂÒƲÙ×÷µÄÒ»¸ö²Ù×÷£¬ÒÔÇ°Ò²¿´µ½¹ý£¬µ«Ò»Ö±Ã»ÓÐÈ¥Ñо¿¹ý£¬Õâ´ÎÏîÄ¿ÖÐÓöµ½ÁË£¬Ò²¾ÍÈ¥Ñо¿ÁËÒ»°Ñ£¬ÆäʵʵÏÖÔ­ÀíҲͦ¼òµ¥µÄ£¬Ëµ°×Á˾ÍÊÇ
Òª¼Ç¼Êý¾Ý¿âÀïµÄÒª½øÐÐÅÅÐò±íµÄ×ܼǼÊýÁ¿£¬È»ºó¸ù¾ÝÑ­»·µÄ´ÎÊý£¬¶àд¼¸¸öÒþ²Ø±äÁ¿£¬½øÐÐÉÏÒÆÏÂÒƲÙ×÷µÄʱºò½øÐÐÅжϾͿÉÒÔÁË¡£
    &n ......

JavaỊ̈߳º´´½¨ÓëÆô¶¯

 
SCJP5ѧϰ±Ê¼Ç
 
Ò»¡¢¶¨ÒåÏß³Ì
 
1¡¢À©Õ¹java.lang.ThreadÀà¡£
 
´ËÀàÖÐÓиörun()·½·¨£¬Ó¦¸Ã×¢ÒâÆäÓ÷¨£º
public void run
()
Èç¹û¸ÃÏß³ÌÊÇʹÓöÀÁ¢µÄ Runnable
ÔËÐжÔÏó¹¹ÔìµÄ£¬Ôòµ÷Óøà Runnable
¶ÔÏóµÄ run
·½·¨£»·ñÔò£¬¸Ã·½·¨²»Ö´ÐÐÈκβÙ×÷²¢·µ»Ø¡£
 
Thread
µÄ×ÓÀàÓ¦ ......

ÔÚjavaÖÐÀûÓÃrhinoÖ´ÐÐjavascript

ÒÔrhinoÖÐÖ´ÐÐQQÓÊÏäµÄsafeauth.jsΪÀý
js´úÂëµØÖ·£ºhttp://res.qqmail.com/zh_CN/htmledition20091127/js/safeauth.js
£¨1£©µ¼ÈëÏàÓ¦Àà
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import com.sun.phobos.script.javascript.RhinoScriptEngineFactory;
£¨2£©½âÎöJS
ScriptEngine ......

JavaµÄFTPЭÒ鼶¿Í»§¶ËʵÏÖÏê½â

10.2.4.3 Àý×Ó3£ºÍøÂçÓ¦ÓòãЭÒéµÄ¿ª·¢
 
       Ç廪´óѧ³ö°æÉ硶Java³ÌÐòÔ±£¬ÉÏ°àÄǵãʶù¡·×÷ÕߣºÖÓÉù——µÚ10Õ¡¶¸ßÊÖÓжà¸ß²ËÄñÓжà²Ë¡·²¿·Ö½ÚÑ¡¡£
       ´ó¼ÒÒ²Ðí¶¼ÓùýFTPÉÏ´«ÏÂÔع¤¾ß£¬±ÈÈç“LeapFTP”Õâ¸ö¹¤¾ßÊÇÒ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ