In this lesson we're going to provide reasons for why we decided to hide some information about how files and URLs work with Java. And how you can write programs using standard Java libraries. Having to understand the details about how files and URLs are used in programming can easily get in the way of solving higher level problems. That's why we provided the edu.duke library and the class FileResource to help you more quickly solve real problems by programming. All languages and all libraries insulate programmers from complex details that can get in the way of solving problems. The libraries we provide are a great insulation and protection for those first learning Java, but even the regular Java classes provide insulation and protection. We've worked to empower you to solve problems, to think creatively about writing programs that will help you learn about programming and problem solving together. Now, we'll show you how to write the hello world program without using the FileResource or URLResource classes. See how this is done could help you implement your own classes to insulate common issues you have while programming. What for us was two classes in the edu.duke package plus a third exception class that some of you may have encountered will be at least six classes in three different packages that are harder to use than the classes we designed. Using the Java libraries will require understanding exceptions and several programming idioms that are more complex than the simple four each loops we started. Let's look at one of the first Java programs we used to print hello world in several languages. This code uses the .edu.FileResource class, and the method run hello, as you can see here. This method prints hello world in different spoken and written languages by reading the text from any languages and printing the words read. The code first creates a FileResource object to reference and read the file containing the words we want to print. Then the method loops over each line in the file using a for each loop as shown here. Reading a string and printing the string in the body of the loop. Let's look at the same code that uses Java not our libraries but rather a way to do this with just the standard Java libraries. This code uses seven classes in three packages. Both programs use the system class. There are many ways to do this, but the one that we're showing will highlight some of the flexibility these extra classes provide to reduce duplicated code. The first step is to create a path object, in the code we've named this object, P. It represents a path to a file in the file system. Here we've used the Paths.get, note the extra s, to get the path. The idea of a path is the same with a file or a URL, something that goes from folder, to folder, to the file in the actual file system. One standard way to read a file in Java is using a BufferedReader from the java.io package. The paths and path classes are in a different package, as we'll soon see. To create a BufferedReader, we first ask the files object again not the s in files to create one for us to use in our program. We'll see other ways to create BufferedReaders when we use a URL instead of a path to a file. We use a loop and the reader dot read line method to read each line of the open file until a null reference is returned by read line. That means the file has been completely read and the loop exits. Both this code and the code with our file resource object use loops but the loops are different. The two main packages we use to read files in Java are java.io and java.nio. The n in nio is for new, though the package is actually old. But it is newer than the java.io package. The i stands for input, reading, and the o stands for output, writing. In other words these are the input output packages. The class's paths, files, and path are in java.nio. These classes, files and paths use static methods, which you have recently learned about. You know that these methods do not belong to a particular instance of a class, but rather the class as a whole. So you do not need to create new objects to use them. Many of the methods for doing reading and writing, as well as some constructors can throw exceptions. Now that you have learned about the basics of exceptions, you know that you should handle these with try catch blocks, and that if you do not handle them, you must add a throws to the appropriate exception type to your method declaration. The java.io package provides other classes for reading and writing. The buffered reader classes often used when reading sources, buffering what is read for good performance. The java.io.io exception class is thrown by many input and output methods. Using these classes requires reading the documentation, and looking at examples, because there are many ways of reading files, raw bytes, or objects, or parsing information. We created the FileResource class to make these things simpler. Let's look at one more example, how to read URLs without using the URL resource by using the Java.net package. Reading URLs with this package is similar to how reading works with our edu.duke.URL resource class. First you create a URL object by providing the string represents the Website. You'll then use this URL object to create a buffered reader, from the java.io class. But that takes several steps. The first step is to open a connection to the associated URL, and get a stream representing its data. Then use this stream to create an InputStreamReader. They use the InputStreamReader to create a buffer reader. That's three step to replace a one step we had in creating a URLs resource object. The purpose of this extra steps is to provide different ways to create an object that implements the reader interface. So that you can read the data from a file or a URL using the same code. So, you read using the same BufferedReader loop that we used in the last example. This kind of reuse is harder to do with our simplified resource classes, and one of the reasons it is useful to take the time to learn more about these complex classes.