java读取tomcat上文件 不好说啊,你把IOException e使用e.printStackTrace()贴出完整的报错信息来看看吧。光一个IOException可没法猜 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你先直接在ie看看能不能打开你要读取的文件。如果可以的话,那就要用e.printStackTrace看看具体什么异常了 如果是http访问的话,需要发送get命令给你一段简单的HTTP客户程序的代码public class HttpClientHttpURLConnection { public static void main(String[] args) throws MalformedURLException, ProtocolException, IOException { URL url = new URL("http://www.debian.org/"); HttpURLConnection urlconn = (HttpURLConnection)url.openConnection(); urlconn.setRequestMethod("GET"); urlconn.setInstanceFollowRedirects(false); urlconn.setRequestProperty("Accept-Language", "ja;q=0.7,en;q=0.3"); urlconn.connect(); Map headers = urlconn.getHeaderFields(); Iterator it = headers.keySet().iterator(); System.out.println("response header:"); while (it.hasNext()){ String key= (String)it.next(); System.out.println(" " + key + ": " + headers.get(key)); } System.out.println("response code:[" + urlconn.getResponseCode() + "] " + "response message:[" + urlconn.getResponseMessage() + "]"); System.out.println("\n---- body ----"); BufferedReader reader = new BufferedReader(new InputStreamReader(urlconn.getInputStream())); while (true){ String line = reader.readLine(); if ( line == null ){ break; } System.out.println(line); } reader.close(); urlconn.disconnect(); }} 高手也指点一下我的!~帖子:请教一个安全问题(java.net.SocketPermission 异常)(在线等...!) 高手进.....http://topic.csdn.net/u/20080803/11/bf7055af-d6e9-4047-86a1-39eaae495b20.html请在原帖处回复。解决后,我马上再开帖加分。我那个贴已经结账了。再开帖的话是80分。 哦,好像听别人说tomcat的问题啊,在tomcat根文件夹下好像不能异地访问?要是想访问只能找别的办法 jsp内置对象out的两个方法out.clear()和out.clearBuffer()的区别 邪门的空指针问题,希望有人能指点,在线等哥哥解决。 spring2.5 支持泛型注入么? jsp生成树状菜单??? 高分悬赏 牛人问题 jsp编译问题 Hibernate怎么样配3表问题啊 请教一个连接池连接释放的问题 ant的安装 -- [ODS-DATA] 对象数据库讨论 -- j2sdkee1.3下如何配置连接sqlserver数据库? 现求hibernate中多表查询语句? axis可以动态调用webservice吗?(思路)
如果可以的话,那就要用e.printStackTrace看看具体什么异常了
给你一段简单的HTTP客户程序的代码public class HttpClientHttpURLConnection {
public static void main(String[] args)
throws MalformedURLException, ProtocolException, IOException { URL url = new URL("http://www.debian.org/"); HttpURLConnection urlconn = (HttpURLConnection)url.openConnection();
urlconn.setRequestMethod("GET");
urlconn.setInstanceFollowRedirects(false);
urlconn.setRequestProperty("Accept-Language", "ja;q=0.7,en;q=0.3"); urlconn.connect(); Map headers = urlconn.getHeaderFields();
Iterator it = headers.keySet().iterator();
System.out.println("response header:");
while (it.hasNext()){
String key= (String)it.next();
System.out.println(" " + key + ": " + headers.get(key));
} System.out.println("response code:[" + urlconn.getResponseCode() + "] " +
"response message:[" + urlconn.getResponseMessage() + "]");
System.out.println("\n---- body ----"); BufferedReader reader =
new BufferedReader(new InputStreamReader(urlconn.getInputStream())); while (true){
String line = reader.readLine();
if ( line == null ){
break;
}
System.out.println(line);
} reader.close();
urlconn.disconnect();
}
}
帖子:请教一个安全问题(java.net.SocketPermission 异常)(在线等...!) 高手进.....
http://topic.csdn.net/u/20080803/11/bf7055af-d6e9-4047-86a1-39eaae495b20.html
请在原帖处回复。解决后,我马上再开帖加分。我那个贴已经结账了。再开帖的话是80分。