InputStream in = s.getInputStream();
byte[] bufin = new byte[1024];
int num = in.read(bufin);
System.out.println(new String(bufin , 0 , num));
// BufferedReader bufin = new BufferedReader(new InputStreamReader(s.getInputStream()));
// String str = bufin.readLine(); //读socket流,因为服务端卡在while那,所以不会发数据给客户端,所以一直卡在这,两边都卡着
// System.out.println(str);
fis.close();
s.close();
}
}
import java.io.*;
import java.net.*;
class InetRece
{
public static void main(String[] args)throws Exception
{
//1。建立ServerSocket服务
ServerSocket ss = new ServerSocket(10006);
//2.获取对象
//获取对象
Socket s = ss.accept();
String ip =s.getInetAddress().getHostAddress();
System.out.println(ip+"...connected");
InputStream in = s.getInputStream();
FileOutputStream fos = new FileOutputStream("E:\\hebing\\server7.jpeg");
//打印连接上的客户端