本帖最后由 べPNヤ 于 2013-10-10 21:20 编辑
public static void TcpSend()throws Exception{
Socket s = new Socket("127.0.0.1",10000);
FileInputStream fis = new FileInputStream(new File("E:\\beautiful.jpg"));
OutputStream os = s.getOutputStream();
byte[] by = new byte[1024];
int len = 0 ;
while((len = fis.read(by))!=-1){
os.write(by,0,len);
}
s.shutdownOutput();
InputStream is = s.getInputStream(); //此处报错 Type mismatch: cannot convert from java.io.InputStream to temp.InputStream 求解 为什么
byte[] byin = new byte[1024];
int num = is.read(byin);
System.out.println(new String(byin,0,num));
fis.close();
s.close();
}
|