本帖最后由 chen20134 于 2014-4-7 16:41 编辑
- class TcpServer implements Runnable
- {
- public void run(){
- ServerSocket ss=new ServerSocket(10005);
- Socket s=ss.accept();
- System.out.println(s.getLocalAddress()+"已连接");
-
- InputStream in = s.getInputStream();
- FileOutputStream fos = new FileOutputStream("server.txt");
- byte[] buf = new byte[1024];
- int len = 0;
- while((len=in.read(buf))!=-1)
- {
- fos.write(buf,0,len);
- }
- OutputStream out=s.getOutputStream(); //这句话报错
- out.write("上传成功".getBytes());
- fos.close();
- s.close();
- ss.close();
- }
- }
复制代码 为什么 OutputStream out=s.getOutputStream(); 这句话报错:类型不匹配
|
|