当前位置: 技术问答>java相关
URLConnection.getOutputStream()相关问题
来源: 互联网 发布时间:2015-06-02
本文导语: try{ URL url=new URL("http://localhost:8080/forum/file/test.txt"); URLConnection uc=url.openConnection(); PrintWriter pw=new PrintWriter(uc.getOutputStream()); pw.write("hello!!!!"); ...
try{
URL url=new URL("http://localhost:8080/forum/file/test.txt");
URLConnection uc=url.openConnection();
PrintWriter pw=new PrintWriter(uc.getOutputStream());
pw.write("hello!!!!");
pw.flush();
}catch(Exception e){e.printStackTrace();}
发布时不能写入;但我试个URL.openURLConnection.getInputStream();又可以,为什么?谢谢!!
URL url=new URL("http://localhost:8080/forum/file/test.txt");
URLConnection uc=url.openConnection();
PrintWriter pw=new PrintWriter(uc.getOutputStream());
pw.write("hello!!!!");
pw.flush();
}catch(Exception e){e.printStackTrace();}
发布时不能写入;但我试个URL.openURLConnection.getInputStream();又可以,为什么?谢谢!!
|
URL url=new URL("http://localhost:8080/forum/file/test.txt");
URLConnection uc=url.openConnection();
//设一下
uc.setDoOutput( true );
uc.setDoInput( true );
uc.setUseCaches( false );
PrintWriter pw=new PrintWriter(uc.getOutputStream()); //最好改为
BufferedOutputStream pw = new BufferedOutputStream(uc.getOutputStream());
pw.write("hello!!!!");
pw.flush();
URLConnection uc=url.openConnection();
//设一下
uc.setDoOutput( true );
uc.setDoInput( true );
uc.setUseCaches( false );
PrintWriter pw=new PrintWriter(uc.getOutputStream()); //最好改为
BufferedOutputStream pw = new BufferedOutputStream(uc.getOutputStream());
pw.write("hello!!!!");
pw.flush();
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。