public class Server {
public static void main(String[] args) throws IOException {
// 服务器
final ServerSocket ss = new ServerSocket(8888);
// 循环接收,,因为服务器不会停
// 解决并发问题----匿名内部类 开 线程
new Thread(){
public void run() {
while(true){
try {
Socket accept = ss.accept();
InputStream is = accept.getInputStream();
// 向服务器硬盘输出的输出流,。还是字节流
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(System.currentTimeMillis()+"aaa.jpg"));
// 边度边写
int len=0;
byte[] b=new byte[1024*8];
while((len=is.read(b))!=-1){
bos.write(b, 0, len);
}