Skip to content

Commit 5918f17

Browse files
开始
1 parent 8ee638b commit 5918f17

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

pom.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,43 @@
77
<groupId>com.yitianyigexiangfa.findsth</groupId>
88
<artifactId>findsth</artifactId>
99
<version>1.0</version>
10+
<build>
11+
<plugins>
12+
<plugin>
13+
<groupId>org.apache.maven.plugins</groupId>
14+
<artifactId>maven-compiler-plugin</artifactId>
15+
<configuration>
16+
<source>6</source>
17+
<target>6</target>
18+
</configuration>
19+
</plugin>
20+
</plugins>
21+
</build>
1022

23+
<dependencies>
24+
<dependency>
25+
<groupId>org.springframework</groupId>
26+
<artifactId>spring-beans</artifactId>
27+
<version>5.1.8.RELEASE</version>
28+
</dependency>
29+
30+
<dependency>
31+
<groupId>org.springframework</groupId>
32+
<artifactId>spring-core</artifactId>
33+
<version>5.1.8.RELEASE</version>
34+
</dependency>
35+
36+
<dependency>
37+
<groupId>org.springframework</groupId>
38+
<artifactId>spring-context</artifactId>
39+
<version>5.1.8.RELEASE</version>
40+
</dependency>
41+
42+
<dependency>
43+
<groupId>org.springframework</groupId>
44+
<artifactId>spring-expression</artifactId>
45+
<version>5.1.8.RELEASE</version>
46+
</dependency>
47+
</dependencies>
1148

1249
</project>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.yitianyigexiangfa.findsth;
2+
3+
import java.io.IOException;
4+
import java.io.InputStream;
5+
import java.net.HttpURLConnection;
6+
import java.net.URL;
7+
import java.nio.charset.Charset;
8+
9+
/**
10+
* @author Bill Lau
11+
* @date 2019-07-28
12+
*/
13+
public class Application {
14+
15+
16+
public static void main(String[] args) throws IOException {
17+
URL url = new URL("https://www.baidu.com");
18+
HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
19+
httpURLConnection.connect();
20+
String responseMessage = httpURLConnection.getResponseMessage();
21+
System.out.println(responseMessage);
22+
int responseCode = httpURLConnection.getResponseCode();
23+
System.out.println(responseCode);
24+
InputStream is = httpURLConnection.getInputStream();
25+
StringBuffer sb=new StringBuffer();
26+
int length=0;
27+
byte[] data=new byte[1024];
28+
while ((length=is.read(data))!=-1){
29+
String s=new String(data, Charset.forName("utf-8"));
30+
sb.append(s);
31+
}
32+
String message=sb.toString();
33+
System.out.println(message);
34+
is.close();
35+
httpURLConnection.disconnect();
36+
}
37+
38+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.yitianyigexiangfa.findsth.constant;
2+
3+
/**
4+
* @author Bill Lau
5+
* @date 2019-07-28
6+
*/
7+
public class FindSthConstant {
8+
9+
private static String[] TOP_DOMAIN_NAMES = new String[]{".com",".cn",".net",".de",
10+
".fi",".co.jp", ".ru",".me", ".edu", ".af", ".ag", ".ai", ".ar",
11+
".au", ".bd", ".bh", ".bn", ".bo", ".br", ".bz", ".co", ".cu",
12+
".cy", ".do", ".ec", ".eg", ".et", ".fj", ".gh", ".gi", ".gt",
13+
".hk", ".jm", ".kh", ".kw", ".lb", ".ly", ".mm", ".mt", ".mx",
14+
".my", ".na", ".nf", ".ng", ".ni", ".np", ".om", ".pa", ".pe",
15+
".pg", ".ph", ".pk", ".pr", ".py", ".qa", ".sa", ".sb", ".sg",
16+
".sl", ".sv", ".tj", ".tr", ".tw", ".ua", ".uy", ".vc", ".vn"};
17+
18+
19+
public static String[] getTopDomainNames() {
20+
return TOP_DOMAIN_NAMES;
21+
}
22+
}

0 commit comments

Comments
 (0)