URL url = new URL("https://username:[email protected]/path"); String userInfo = url.getUserInfo(); System.out.println(userInfo); // output: username:passwordIn this example, we create a URL object using a string representation of the URL. We retrieve the username and password information by calling the getUserInfo() method and printing it to the console. The package library for the java.net URL class is the java.net package, which provides networking support for Java programs.