请各位师兄帮忙看看,这是我自己写的
试过了,可以运行
没显示OK,到底有哪些错误?
-------------------------------------------------
package test;
import java.net.*;
import java.io.*;
public class PicServer {
public static void main(String[] args) throws Exception {
ServerSocket ss = new ServerSocket(10059);
Socket s = ss.accept();
BufferedInputStream bufIn =
new BufferedInputStream(s.getInputStream());
BufferedOutputStream bufOut =
new BufferedOutputStream(new FileOutputStream("E:\\zz.jpg"));
int by;
while((by=bufIn.read())!=-1){
bufOut.write(by);
}
PrintWriter out = new PrintWriter(s.getOutputStream(),true);
out.println("OK".getBytes());
bufOut.close();
s.close();
ss.close();
}
}
----------------------------------------------------
package test;
import java.net.*;
import java.io.*;
public class PicClient {
public static void main(String[] args) throws Exception {
Socket s = new Socket("192.168.1.101",10059);
BufferedInputStream bufIn =
new BufferedInputStream(new FileInputStream("E:\\008.jpg"));
BufferedOutputStream bufOut =
new BufferedOutputStream(s.getOutputStream());
int by;
while((by=bufIn.read())!=-1){
bufOut.write(by);
}
s.shutdownOutput();
BufferedInputStream bis = new BufferedInputStream(s.getInputStream());
if((by=bis.read())!=-1)
bufOut.write(by);
bufIn.close();
s.close();
}
}
------------------------------------------------
|
|