<div class="article_content">1.使用url:
<div style="border-right: 1px solid #cccccc; padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: #eeeeee; border: 1px solid #cccccc;"><span style="color: #000000;">url url</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">new</span> <span style="color: #000000;"> url(</span> <span style="color: #000000;">"</span> <span style="color: #000000;">ftp://javaa:javaa@172.168.2.222:21/test/javaa.txt</span> <span style="color: #000000;">"</span> <span style="color: #000000;">);<br>printwriter pw</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">new</span> <span style="color: #000000;"> printwriter(url.openconnection().getoutputstream());<br>pw.write(</span> <span style="color: #000000;">"</span> <span style="color: #000000;">this is a test</span> <span style="color: #000000;">"</span> <span style="color: #000000;">);<br>pw.flush();<br>pw.close();</span>
本文提供了一个使用Java通过FTP协议上传文件的示例代码。该示例展示了如何创建URL对象来指定FTP服务器地址及文件路径,并通过PrintWriter将字符串写入远程服务器上的文件。
1188

被折叠的 条评论
为什么被折叠?



