[Java] 纯文本查看 复制代码 public static void main(String[] args) throws IOException{
Socket s = new Socket("192.168.22.171", 8002);
BufferedInputStream bis = new BufferedInputStream(new FileInputStream("C:\\Users\\铁王座的继承人\\Documents\\java就业班视频资料\\day08\\素材\\itcast\\mn.jpg"));
BufferedOutputStream bos = new BufferedOutputStream(s.getOutputStream());
byte[] bys = new byte[1024];
int len;
while ((len = bis.read(bys)) != -1){
bos.write(bys,0,len);
}
s.shutdownOutput();
BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
String line = br.readLine();
System.out.println("服务器反馈:"+line);
s.close();
} |