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根文件夹下好像不能异地访问?要是想访问只能找别的办法 spring + hibernate连接多个数据库 怎样写一个自己的加密解密类呢? 大家推荐一下判断两篇文章相似度方法?我尝试用lucene模糊搜索可以很好判断5、6个字的标题,但内容就不行了?有什么框架或方法可以实现? 遗传算法 hibernate3.0不能连接oracle8.0.0.5的问题 在jsp页面中如何点击链接 返回 后可以回到上一页,谢谢 请教一个简单的问题 jboss4.0.3sp1启动时报错疑问 安装weblogic8.2时出现问题 求大神看看,这段代码有没有错误 现求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分。