当前位置: 代码迷 >> J2SE >> 为什么会抛出java.io.FileNotFoundException哪,路径是对的啊各位高人帮帮忙啊该如何解决
  详细解决方案

为什么会抛出java.io.FileNotFoundException哪,路径是对的啊各位高人帮帮忙啊该如何解决

热度:88   发布时间:2016-04-24 14:47:15.0
为什么会抛出java.io.FileNotFoundException哪,路径是对的啊,各位高人帮帮忙啊
具体的程序是这样的:
String   urlString   =   "ftp://username:password@ftpserver地址/windows_xp/file.txt ";
try{
URL   url   =   null;
url   =   new   URL(urlString);
URLConnection   urlconn   =   url.openConnection();
InputStream   is   =   urlconn.getInputStream();
InputStreamReader   isr   =   new   InputStreamReader(urlconn.getInputStream());
BufferedReader   br   =   new   BufferedReader(isr);
String   line;
while(null   !=   (line   =   br.readLine())){
                        .............
                }
}catch   (IOException   e)   {
      .............
      throw   new   BatchException(msg,   e);  
}finally   {
      .............
}

这个ftp文件用IE浏览器可以访问,程序里也捕捉了IOException异常了,哪错了哪,拜托各位高人指点迷津。

------解决方案--------------------
我测试是正常的,没什么问题

import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class TestFtp {
public static void main(String[] args) {
String urlString = "ftp://qiuyb:xxxxxx@localhost/Class.java ";
try{
URL url = null;
url = new URL(urlString);
URLConnection urlconn = url.openConnection();
InputStreamReader isr = new InputStreamReader(urlconn.getInputStream());
BufferedReader br = new BufferedReader(isr);
String line;
while(null != (line = br.readLine())){
System.out.println(line);
}
}catch (IOException e) {
e.printStackTrace();
}
}
}

能打印出Class.java文件的内容来
------解决方案--------------------
学习
------解决方案--------------------
学习学习
------解决方案--------------------
程序没问题。楼主查查其它方面的吧。
------解决方案--------------------
我的测试也是没有问题的,搂住在好好检查一下。
------解决方案--------------------
我是来jf的~~~帮顶
------解决方案--------------------
我也是来jf的~~~
  相关解决方案