Java???е???servlet
???????????? ???????[ 2015/11/25 13:35:47 ] ??????????????????? ???????
???????Java?е???servlet?????
????????????????????Java???е???Servlet???????Щ???????????JavaAPI?????????URL????????openStream( )?????????URL?????????????????????????????InputStream??
????????Java?е???servlet??t?????
package com.solid.test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
public class TestCallServlet {
//servlet·??
private static final String path = "http://localhost:8080/test/servlet/TestServlet";
/**
* ???????servlet????
* @param args
*/
public static void main(String[] args) {
try {
URL url = new URL(path);
url.openStream();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
?????????????????????????t?????
package com.solid.test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
public class TestReaderSource {
//URL·??
private static final String path = "http://www.google.cn";
//???path·???????????????????
public static void main(String[] args) {
BufferedReader br = null;
String source;
try {
URL url = new URL(path);
URLConnection conn = url.openConnection();
br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while((source=br.readLine())!=null) {
System.out.println(source);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if(br != null) {
br.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11