- 博客(5)
- 收藏
- 关注
原创 Java网络编程---URL下载网络资源
public class UrlDemo { public static void main(String[] args) throws Exception{ //1.创建URL对象 URL url = new URL("..."); //2.连接资源 Http HttpURLConnection connection = (HttpURLConnection) url.openConnection(); //3.获取流
2022-02-17 20:31:07 64
原创 Java网络编程---UDP聊天实现
发送方public class UdpSendDemo { public static void main(String[] args) throws Exception{ //1.建立一个socket DatagramSocket datagramSocket = new DatagramSocket(888); while (true){ //2.准备数据,从控制台获取 .
2022-02-17 17:53:24 416
原创 Java网络编程---TCP实现上传文件
服务端```java```javapublic class TcpServerDemo01 { public static void main(String[] args) throws Exception{ //1.创建服务 ServerSocket serverSocket = new ServerSocket(99); //2.监听连接 Socket accept = serverSocket.accept(); .
2022-02-17 16:25:25 95
原创 Java网络编程---TCP实现聊天
客户端//客户端public class TcpClientDemo { public static void main(String[] args) throws IOException { //1.知道地址和端口 InetAddress inetAddress = InetAddress.getByName("127.0.0.1"); int port = 88; //2.创建连接 Socket socket.
2022-02-16 22:26:39 95
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人