A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© zl78365336 中级黑马   /  2013-11-21 20:35  /  1018 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

请各位师兄帮忙看看,这是我自己写的
         试过了,可以运行
没显示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();
        }
}

------------------------------------------------

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马