public class UploadPicServer {
public static void main(String[] args) throws FileNotFoundException, IOException {
// 创建tcp的socket服务端。
ServerSocket ss = new ServerSocket(10006);
// 获取客户端。
Socket s = ss.accept();
String ip = s.getInetAddress().getHostAddress();
System.out.println(ip + "......connected");
// 读取客户端发来的数据。
InputStream in = s.getInputStream();
// 将读取到的数据存储到一个文件中。
File dir = new File("d:\\pic");
if (!dir.exists()) {
dir.mkdirs();
}
File file = new File(dir, ip + ".bmp");
FileOutputStream fos = new FileOutputStream(file);