📄 helloclient.java
字号:
package cli;import java.io.*;import java.net.HttpURLConnection;import java.net.URL;public class HelloClient { public static void main(String[] args) { try { callServlet(); } catch (Exception e) { e.printStackTrace(); } } private static void callServlet() throws IOException { URL url = new URL("http", "localhost", 80, "/SimpleOzoneServlet/HelloServlet"); System.out.println("Connecting to " + url); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); String response = reader.readLine(); do { System.out.println(response); response = reader.readLine(); } while (response != null); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -