Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 429739d

Browse files
second example network programming
1 parent 2b6f88e commit 429739d

File tree

3 files changed

+54
-40
lines changed

3 files changed

+54
-40
lines changed

‎.idea/workspace.xml

Lines changed: 30 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example.hello_world_package;
2+
3+
4+
import java.net.*;
5+
6+
public class Network_Programming_2 {
7+
8+
9+
public static void main(String[] args) {
10+
try {
11+
URL url = new URL("https://www.geeksforgeeks.org/url-class-java-examples/");
12+
13+
System.out.println("Protocol: " + url.getProtocol());
14+
System.out.println("Host Name: " + url.getHost());
15+
System.out.println("Port Number: " + url.getPort()); //returns -1 since no port no specified by us in the url
16+
System.out.println("Port Number: " + url.getDefaultPort());//returns default port no for the protocol here for HTTPS 443
17+
System.out.println("File Name: " + url.getFile());
18+
19+
} catch (Exception e) {
20+
System.out.println(e);
21+
22+
}
23+
}
24+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /