04.22 Using URL class in Java

Lecture 4.22: Using URL class in Java by Dr. Partha Roy JAVA PLAYLIST:    • JAVA PROGRAMMING   Networking in JAVA When HTTP is used to read from a URL, the data must be received in the order in which it was sent. Otherwise, we end up with a jumbled HTML file, a corrupt zip file, or some other invalid information. The java.net package contains two classes to help us write Java programs that use TCP/IP to send and receive packets over the network: Socket and ServerSocket. Only one client can connect to a server at a time for communication. A computer has a single physical connection to the network. All data destined for a particular computer arrives through that connection. However, the data may be intended for different applications running on the same computer. So how does the computer know to which application to forward the data? Through the use of ports. Data transmitted over the Internet is accompanied by addressing information that identifies the computer and the port for which it is destined. The computer machine is identified by its 32-bit IP address, which IP uses to deliver data to the right computer on the network.. Ports are identified by a 16-bit number, which TCP and UDP use to deliver the data to the right application in the same computer machine. In connection-based communication such as TCP, a server application binds a socket to a specific port number. This has the effect of registering the server with the system to receive all data destined for that port. A client can then communicate with the server at the server's port. Port numbers range from 0 to 65,535 because ports are represented by 16-bit numbers. The port numbers ranging from 0 to 1023 are restricted or reserved; they are reserved for use by well-known services such as HTTP and FTP and other system services. These ports are called well-known ports. URL ( Uniform Resource Locator) •URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on the Internet or Intranet. •A URL has two main components: Protocol identifier: For the URL http://example.com, the protocol identifier is http. Resource name: For the URL http://example.com, the resource name is example.com. •Note that the protocol identifier and the resource name are separated by a colon and two forward slashes. The protocol identifier indicates the name of the protocol to be used to fetch the resource. The example uses the Hypertext Transfer Protocol (HTTP), which is typically used to serve up hypertext documents. •HTTP is just one of many different protocols used to access different types of resources on the net. Other protocols include File Transfer Protocol (FTP), Gopher, File, and News. •The resource name is the complete address to the resource. The format of the resource name depends entirely on the protocol used, but for many protocols, including HTTP, the resource name contains one or more of the following components: Host Name: The name of the machine on which the resource lives. Filename: The pathname to the file on the machine. Port Number: The port number to which to connect (typically optional). Reference: A reference to a named anchor within a resource that usually identifies a specific location within a file (typically optional). •public final class URL extends Object implements Serializable •Inheritance hierarchy: java.lang.Object java.net.URL •Class URL represents a Uniform Resource Locator, a pointer to a "resource" on the World Wide Web. A resource can be something as simple as a file or a directory, or it can be a reference to a more complicated object, such as a query to a database or to a search engine. •Constructors: URL(String s) Creates a URL object from the String representation. URL(String protocol, String host, int port, String file) Creates a URL object from the specified protocol, host, port number, and file. URL(String protocol, String host, String file) Creates a URL from the specified protocol name, host name, and file name. Learn Java to solve problems with Netbeans IDE Are you ready to learn Java from scratch? In this comprehensive masterclass, we cover everything you need to go from a total beginner to writing your own functional Java applications. Whether you're a student, an aspiring software engineer, or a hobbyist, this tutorial is designed to be the only starting point you need. Java remains one of the most popular programming languages in the world. It powers Android apps, enterprise-level server applications, and massive big-data platforms. Learning Java gives you a rock-solid foundation for almost any other language like C#, C++, or Python. Don't forget to Subscribe ✅ and Hit the Bell 🔔 icon to stay updated with more coding tutorials!

Java Full Course for Beginners
▶︎

Java Full Course for Beginners

System Design was HARD until I Learned these 30 Concepts
▶︎

System Design was HARD until I Learned these 30 Concepts

Access Modifiers in C# Explained | Public, Private, Protected, Internal & Interview Tips - Chapter 4
▶︎

Access Modifiers in C# Explained | Public, Private, Protected, Internal & Interview Tips - Chapter 4

Object Oriented Programming with Python - Full Course for Beginners
▶︎

Object Oriented Programming with Python - Full Course for Beginners

Creator of C++: Bell Labs, Negative Overhead Abstraction, Mistakes | Bjarne Stroustrup
▶︎

Creator of C++: Bell Labs, Negative Overhead Abstraction, Mistakes | Bjarne Stroustrup

Using Large Language Models | Build Your Own LLM Workshop #1
▶︎

Using Large Language Models | Build Your Own LLM Workshop #1

Android 17 sucks. So I put Linux on a phone.
▶︎

Android 17 sucks. So I put Linux on a phone.

Build a Complete Medical Chatbot with LLMs, LangChain, Pinecone, Flask & AWS 🔥
▶︎

Build a Complete Medical Chatbot with LLMs, LangChain, Pinecone, Flask & AWS 🔥

How to Start Coding | Programming for Beginners | Learn Coding | Intellipaat
▶︎

How to Start Coding | Programming for Beginners | Learn Coding | Intellipaat

05.02 Collections Framework Set in Java
▶︎

05.02 Collections Framework Set in Java

God Says:"DON’T IGNORE THIS IMPORTANT LETTER I SENT YOU"/God Message Now/God Message
▶︎

God Says:"DON’T IGNORE THIS IMPORTANT LETTER I SENT YOU"/God Message Now/God Message

At Our Son's New House Party, My Wife Whispered, "We Have To Go"—What She Said... | Calm Dad Stories
▶︎

At Our Son's New House Party, My Wife Whispered, "We Have To Go"—What She Said... | Calm Dad Stories

ساعة من السكينة مع القرآن❤️😌 | تلاوة هادئة للنوم والاسترخاء🕊️🎧 | Deep Tranquility
▶︎

ساعة من السكينة مع القرآن❤️😌 | تلاوة هادئة للنوم والاسترخاء🕊️🎧 | Deep Tranquility

Buying Goats From Farmers | 3-Wheeled Truck Packed Full for Village Market
▶︎

Buying Goats From Farmers | 3-Wheeled Truck Packed Full for Village Market

10 Hidden Social Rules in Germany Nobody Warns You About!
▶︎

10 Hidden Social Rules in Germany Nobody Warns You About!

Revealing The SPECIAL TECHNIQUE Of A Pakistani Man To EXTRACT GOLD From Used Motherboard Waste
▶︎

Revealing The SPECIAL TECHNIQUE Of A Pakistani Man To EXTRACT GOLD From Used Motherboard Waste

God Says:"MY CHILD, I NEED TO SEE YOU URGENTLY!"/God Message Now/God Message
▶︎

God Says:"MY CHILD, I NEED TO SEE YOU URGENTLY!"/God Message Now/God Message

But what are Hamming codes? The origin of error correction
▶︎

But what are Hamming codes? The origin of error correction

Kubernetes Tutorial for Beginners [FULL COURSE in 4 Hours]
▶︎

Kubernetes Tutorial for Beginners [FULL COURSE in 4 Hours]

God Says:"A CALL FROM GOD — OPEN IMMEDIATELY!"/God Message Now/God Message
▶︎

God Says:"A CALL FROM GOD — OPEN IMMEDIATELY!"/God Message Now/God Message