这里是代码,我人都傻了
<code>
private void startSocket(String newspapername) {
Socket client;
try {
client = new Socket("localhost", 6666);
OutputStream os = client.getOutputStream();
os.write(newspapername.getBytes());
/*
* 接收服务端消息
*
*/
InputStream is=client.getInputStream();
byte[] message = new byte[1024*1024];
int len = is.read(message);
if(len!=-1) {
ByteArrayInputStream input=new ByteArrayInputStream(message);
System.out.println(message);
BufferedImage bi1 =ImageIO.read(input);
System.out.println(bi1);
}else {
System.out.println("获取资源失败,请联系管理员");
}
os.close();
client.close();
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println("服务端连接失败!");
System.out.println(e);
}
}
</code>
已解决问题