⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 请问:在java中怎样实现ftp_百度知道.htm

📁 主要是我最近两月在公司通过百度学习的内容,有AJAX,DWR,JAVA实现文件的上传和下载.主要目的在与告诉大家一个成功程序员(JAVA)是如何学习的,需要学习什么内容.以及学习的态度.
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0045)http://zhidao.baidu.com/question/4201805.html -->
<!--STATUS OK--><HTML><HEAD><TITLE>请问:在Java中怎样实现ftp_百度知道</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312"><LINK 
title="“请问:在Java中怎样实现ftp”的最新回答(RSS 2.0)" 
href="http://zhidao.baidu.com/q?ct=20&amp;qid=4201805&amp;pn=65535&amp;rn=25&amp;tn=rssqb" 
type=application/rss+xml rel=alternate><LINK 
href="请问:在Java中怎样实现ftp_百度知道.files/iknow.css" type=text/css rel=stylesheet>
<META content="MSHTML 6.00.2900.3059" name=GENERATOR></HEAD>
<BODY>
<DIV id=usrbar><NOBR>
<SCRIPT language=JavaScript>document.write('<a href="http://www.baidu.com/">百度首页</a>&nbsp;|&nbsp;<a href="http://passport.baidu.com/?login&tpl=ik&u='+escape(location.href)+'">登录</a>');</SCRIPT>
</NOBR></DIV>
<TABLE class=hd cellSpacing=0 cellPadding=0 width=750 border=0>
  <TBODY>
  <TR>
    <TD vAlign=top width=146><A href="http://zhidao.baidu.com/"><IMG height=46 
      alt=百度知道 src="请问:在Java中怎样实现ftp_百度知道.files/logo-zhidao.gif" width=137 
      vspace=3 border=0></A></TD>
    <TD>
      <DIV id=tab><A href="http://news.baidu.com/">新闻</A>&nbsp;&nbsp;&nbsp;<A 
      href="http://www.baidu.com/">网页</A>&nbsp;&nbsp;&nbsp;<A 
      href="http://post.baidu.com/">贴吧</A>&nbsp;&nbsp;&nbsp;<STRONG>知道</STRONG>&nbsp;&nbsp;&nbsp;<A 
      href="http://mp3.baidu.com/">MP3</A>&nbsp;&nbsp;&nbsp;<A 
      href="http://image.baidu.com/">图片</A>&nbsp;&nbsp;&nbsp;<A 
      href="http://baike.baidu.com/">百科</A></DIV>
      <TABLE cellSpacing=0 cellPadding=0 border=0>
        <TBODY>
        <TR>
          <FORM name=ftop action=/q method=get>
          <TD noWrap><INPUT class=hdi tabIndex=1 maxLength=256 size=42 
            name=word>&nbsp;&nbsp;&nbsp;</TD>
          <TD><A 
        href="http://www.baidu.com/search/zhidao_help.html">帮助</A></TD></TR></TBODY></TABLE>
      <DIV style="MARGIN-TOP: 4px"><INPUT class=bnsrh tabIndex=2 type=submit value=搜索答案><INPUT 
      type=hidden value=17 name=ct><INPUT type=hidden value=0 name=pn><INPUT 
      type=hidden value=ikaslist name=tn><INPUT type=hidden value=10 name=rn><INPUT class=bnsrh style="MARGIN-LEFT: 8px" onclick=ask(ftop); tabIndex=3 type=button value=我要提问></DIV></FORM>
      <FORM name=fask action=/q method=get><INPUT type=hidden value=17 
      name=ct><INPUT type=hidden value=0 name=pn><INPUT type=hidden value=ikask 
      name=tn><INPUT type=hidden value=12 name=rn><INPUT type=hidden name=word> 
      <INPUT type=hidden value=1 name=cm><INPUT type=hidden value=394496 
      name=lm></FORM></TD></TR></TBODY></TABLE>
<SCRIPT language=JavaScript>function ask(fn){document.fask.word.value=fn.word.value;fask.submit();}</SCRIPT>

<SCRIPT>
document.domain="baidu.com";
var url = escape(location.href);

function ctlSubmit(event) {
	if (event.ctrlKey && event.keyCode == 13) {	fdf.submit()	}
}
function checkco(f,des)
{ if(f.co.value=="") {alert("请输入您的"+des); return false;}}
function limitpl(f,des)
{ if(f.co.value=="") {alert("请输入您的"+des); return false;} return limitChars(f.co,des,200);}
function checkcoAndsn(f,des)
{ if(f.co.value=="") {alert("请输入您的"+des); return false;} return limitChars(f.sn,"参考资料",60);}
function cReply(flag)
{ if (flag=="yes") {
document.getElementById('replyTB').style.display=""; }
if(flag=="no"){document.getElementById('replyTB').style.display="none"; }
location.hash="here";
}
function fixReply(flag){ setTimeout("cReply('"+flag+"')",300);}
function limitChars(obj,obj_Str,limit_len)
{
	var c = getLeftChars(obj,limit_len);
	if(c<0) 
	{
	  echo_str = obj_Str + "限定在"+limit_len+"个字以内,请缩短字数";
      alert(echo_str);
      obj.focus();
      return false;    
	}
return true;	
}
function getLeftChars(varField,limit_len) {
    var i = 0;
     var cap = limit_len*2;    
    var j=0;
   var runtime = (varField.value.length>cap)?(cap+1):varField.value.length;
    for (i = 0; i< runtime; i++) {     
     if (varField.value.charCodeAt(i) > 127 || varField.value.charCodeAt(i) == 94) {
        j=j+2;  
        } 
     else {
        j=j+1
     }   
    }  
    var leftchars = cap - j;    
    return (leftchars);
}
function  showcpro(cproshowstr)
{
	document.getElementById("cproshow").innerHTML=cproshowstr;
}
</SCRIPT>

<DIV id=main><!--[if IE]>
<SCRIPT language=JavaScript>
var objmain = document.getElementById("main");
function updatesize(){ var bodyw = window.document.body.offsetWidth; if(bodyw <= 792) objmain.style.width="752px"; else if(bodyw >= 1016) objmain.style.width="976px"; else objmain.style.width="100%"; }
updatesize(); window.onresize = updatesize;
</SCRIPT>
<![endif]--><!-- 广告 -->
<DIV 
style="BACKGROUND: none transparent scroll repeat 0% 0%; MARGIN: 10px 0px 0px" 
align=left>
<TABLE height=90 cellSpacing=0 cellPadding=0 width=760 border=0>
  <TBODY>
  <TR>
    <TD>
      <DIV style="POSITION: relative"><EMBED style="POSITION: absolute" 
      pluginspage=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash 
      src=http://eiv.baidu.com/maimg/20070215/1098151735.swf width=760 height=90 
      type=application/x-shockwave-flash wmode="opaque" quality="high"> <A 
      style="CURSOR: pointer" 
      href="http://ma.baidu.com/ma/rcv/click.php?gid=1&amp;sid=11722&amp;wid=1&amp;kid=1&amp;opos=1&amp;fn=iknow&amp;url=http%3A%2F%2Fwww.baidu.com%2Fevents%2F20070215%2Findex.html&amp;key=d311c6bbdb2d9da7d80a03f189075067&amp;s=49c75c48429762a5&amp;sn=71&amp;rpos=1" 
      target=_blank>
      <DIV 
      style="Z-INDEX: 10; BACKGROUND: #cdeaf6; FILTER: alpha(opacity=0); LEFT: 0px; WIDTH: 760px; POSITION: relative; TOP: 0px; HEIGHT: 90px; moz-opacity: 0"></DIV></A></DIV></TD></TR></TBODY></TABLE></DIV><!-- 广告结束 -->
<DIV class=path><A href="http://zhidao.baidu.com/">百度知道</A> &gt; <CC><A 
href="http://zhidao.baidu.com/browse/74?lm=9">电脑/网络</A> &gt; <A 
href="http://zhidao.baidu.com/browse/93?lm=9">编程</A></CC></DIV>
<DIV id=right>
<DIV class="t3 bcy bgy" 
style="BORDER-RIGHT: #64b7d7 1px solid; BORDER-TOP: #64b7d7 1px solid; BACKGROUND: #deeef4; BORDER-LEFT: #64b7d7 1px solid; BORDER-BOTTOM: medium none">相关问题</DIV>
<DIV class="b3 bcy mb12" 
style="BORDER-RIGHT: #64b7d7 1px solid; BORDER-TOP: medium none; BORDER-LEFT: #64b7d7 1px solid; BORDER-BOTTOM: #64b7d7 1px solid">
<TABLE class=wr cellSpacing=0 cellPadding=0 border=0>
  <TBODY>
  <TR>
    <TD vAlign=top width=10>&#8226; </TD>
    <TD class=f14><A 
      href="http://zhidao.baidu.com/question/14704706.html?fr=qrl3" 
      target=_blank>java:与FTP相关的东东</A></TD></TR>
  <TR>
    <TD vAlign=top width=10>&#8226; </TD>
    <TD class=f14><A 
      href="http://zhidao.baidu.com/question/6280044.html?fr=qrl3" 
      target=_blank>什么是蓝牙?什么是Java?它们具体应用举例。</A></TD></TR>
  <TR>
    <TD vAlign=top width=10>&#8226; </TD>
    <TD class=f14><A 
      href="http://zhidao.baidu.com/question/9597327.html?fr=qrl3" 
      target=_blank>什么是JSP,JAVA又是什么?各有什么作用呢?</A></TD></TR>
  <TR>
    <TD vAlign=top width=10>&#8226; </TD>
    <TD class=f14><A 
      href="http://zhidao.baidu.com/question/16780236.html?fr=qrl3" 
      target=_blank>JavaScrip和Java一样吗?</A></TD></TR>
  <TR>
    <TD vAlign=top width=10>&#8226; </TD>
    <TD class=f14><A 
      href="http://zhidao.baidu.com/question/17216395.html?fr=qrl3" 
      target=_blank>大家好,我想学习JAVA编程!大家能不能给我提一点建议.</A></TD></TR>
  <TR>
    <TD width=10>&nbsp;</TD>
    <TD align=left height=22><A class=lmore_relaques 
      href="http://zhidao.baidu.com/q?word=请问:在Java中怎样实现ftp&amp;ct=17&amp;pn=0&amp;tn=ikaslist&amp;rn=10&amp;fr=qrl4">更多&gt;&gt;</A></TD></TR></TBODY></TABLE></DIV>
<DIV class=mb12><A title=订阅“请问:在Java中怎样实现ftp”的最新回答 
href="http://zhidao.baidu.com/q?ct=20&amp;qid=4201805&amp;pn=65535&amp;rn=25&amp;tn=rssqb" 
target=_blank><IMG height=14 src="请问:在Java中怎样实现ftp_百度知道.files/rss_xml.gif" 
width=36 align=absMiddle border=0></A>&nbsp;&nbsp;订阅该问题</DIV>
<DIV class=cprodiv id=cproshow></DIV>
<DIV class="b4y gray mb12">您想在自己的网站上展示百度“知道”上的问答吗?来<A 
href="http://zhidao.baidu.com/iknowcode.html" target=_blank>获取免费代码</A>吧! 
<HR SIZE=1>
如要投诉或提出意见建议,请到<BR><A 
href="http://post.baidu.com/f?kw=%B0%D9%B6%C8%D6%AA%B5%C0%CD%B6%CB%DF" 
target=_blank>百度知道投诉吧</A>反馈。 </DIV></DIV>
<DIV id=center>
<DIV class=bai>
<DIV class="t3_favor bcg bgg"><SPAN style="PADDING-RIGHT: 10px; FLOAT: right"><A 
onclick="window.open('http://cang.baidu.com/do/add?it='+encodeURIComponent(document.title)+'&amp;iu='+encodeURIComponent(location.href)+'&amp;tn=%E7%9F%A5%E9%81%93%E9%97%AE%E9%A2%98%2C&amp;fr=ik#nw=1','_s','scrollbars=no,width=600,height=450,right=75,top=20,status=no,resizable=yes'); return false;" 
href="http://cang.baidu.com/do/add" target=_blank>添加到搜藏</A></SPAN><SPAN 
style="PADDING-LEFT: 10px"><CS4 />已解决</SPAN></DIV>
<DIV class="b3 bcg mb12">
<DIV class=p90>
<DIV class="f14 B wr"><CQ>请问:在Java中怎样实现ftp</CQ></DIV>
<DIV class=wr><SPAN class=red><IMG height=16 
src="请问:在Java中怎样实现ftp_百度知道.files/icn_point.gif" width=16 align=absMiddle> 
悬赏分:0</SPAN> - <SPAN class=gray>提问时间2006-2-24 20:06</SPAN></DIV>
<DIV class="f14 wr"><CD>我是这个方面的菜鸟,请指点</CD></DIV>
<DIV class="f14 wr"></DIV>
<DIV class=gray align=right>提问者:<A 
href="http://passport.baidu.com/?detail&amp;aid=7&amp;default_tab=2&amp;un=susan1982498" 
target=_blank>susan1982498</A> - <A 
href="http://www.baidu.com/search/zhidao_help.html#n5" target=_blank>试用期 一级</A> 
</DIV></DIV></DIV>
<DIV class="t3 bcg bgg" style="POSITION: relative">其他回答
<DIV 
style="FONT-WEIGHT: normal; FONT-SIZE: 12px; RIGHT: 10px; POSITION: absolute; TOP: 4px">共 
1 条</DIV></DIV>
<DIV class="b3 bcg mb12">
<DIV class="p90 wr"><A name=18382549>
<DIV class=f14>使用ftpClient类 <BR><BR>ftpClient的文件路径是相对路径还是绝对路径和Ftp 
Server的类型有关,我就遇到过wu-ftp是相对路径而vs-ftp是绝对路径的问题,所以你最好在put文件的时候不要用/xxx/xxx这种绝对路径的书写方式。还有ftp用户权限问题,linux下root不能作为ftp用户的所以通常用的用户不一定能够在你的目的路径下有写文件的权限,所以一定要建好目录再传。这个没有什么实际例子,我用的也是网上的例子。 
<BR>public boolean sendFile(String filepathname, String distfilepathname) { 
<BR>boolean result = true; <BR>if (aftp != null) { 
<BR>System.out.println("正在粘贴文件,请耐心等待...."); <BR><BR>String contentperline; 
<BR>try { <BR>a = "粘贴成功!"; <BR>String fg = new String("/"); <BR>int index = 
filepathname.lastIndexOf(fg); <BR>String filename = filepathname.substring(index 
+ 1); <BR>File localFile; <BR>localFile = new File(filepathname); 
<BR>RandomAccessFile sendFile = new RandomAccessFile(filepathname, "r"); <BR>// 
<BR>sendFile.seek(0); <BR>outs = aftp.put(distfilepathname); <BR>outputs = new 
DataOutputStream(outs); <BR>while (sendFile.getFilePointer() &lt; 
sendFile.length()) { <BR>ch = sendFile.read(); <BR>outputs.write(ch); <BR>} 
<BR>outs.close(); <BR>sendFile.close(); <BR>//FileOperator fop = new 
FileOperator(); <BR>//fop.DeleteFile(filepathname); <BR>}catch (IOException e) { 
<BR>a = "粘贴失败!"; <BR>result = false; <BR>} <BR>System.out.println(a); <BR>// 
<BR>}else { <BR>result = false; <BR>} <BR>return result; <BR>} <BR><BR><SPAN 
style="COLOR: #666666">参考资料:<A href="http://www.tiantiansoft.com/" 
target=_blank>http://www.tiantiansoft.com/</A> </SPAN></DIV>
<DIV class=gray align=right>回答者:<A 
href="http://passport.baidu.com/?detail&amp;aid=7&amp;default_tab=2&amp;un=%B7%E3%D2%B6%C6%AE%C1%E32008" 
target=_blank>枫叶飘零2008</A> - <A 
href="http://www.baidu.com/search/zhidao_help.html#n5" target=_blank>经理 四级</A> 
2-24 20:10</DIV>
<DIV id=Lg></DIV></DIV></DIV></DIV></DIV></DIV>
<SCRIPT src="请问:在Java中怎样实现ftp_百度知道.files/zhidao.js"></SCRIPT>

<SCRIPT src="请问:在Java中怎样实现ftp_百度知道.files/cpronum_iknow.js"></SCRIPT>

<SCRIPT language=javascript>
var arrBaiduCproConfig=new Array();
arrBaiduCproConfig['n'] = 'baiduiknow_cpr';			
arrBaiduCproConfig['tm'] = 24;					
arrBaiduCproConfig['cm'] = 60;					
arrBaiduCproConfig['um'] = 24;					
arrBaiduCproConfig['rad'] = 1;				
arrBaiduCproConfig['cad'] = 0;					
arrBaiduCproConfig['wn'] = 1;					
arrBaiduCproConfig['bg'] = '#ffffff';				
arrBaiduCproConfig['tt'] = '#000000';				
arrBaiduCproConfig['ct'] = '#000000';				
arrBaiduCproConfig['url'] = '#000000';			
arrBaiduCproConfig['ta'] = 'right';			
arrBaiduCproConfig['tl'] = 'top';					
arrBaiduCproConfig['tn'] = 'baiduCPROiknow';		
cpro_top_space=700;
cpro_everyadvheight=100;	
cpro_maxnum=cpronum_iknow;
cpro_num=(document.body.scrollHeight-cpro_top_space)/cpro_everyadvheight;
cpro_num=cpro_num>cpro_maxnum?cpro_maxnum:cpro_num;
cpro_num=parseInt(cpro_num, 10);
arrBaiduCproConfig['hn'] =cpro_num;
if(cpro_num>0){
	document.write(baiduCproIFrame());
}
</SCRIPT>

<DIV id=ft>&copy;2007 Baidu</DIV><IMG style="DISPLAY: none" src=""> </BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -