Book Image

The Java Workshop

By : David Cuartielles, Andreas Göransson, Eric Foster-Johnson
4 (2)
Book Image

The Java Workshop

4 (2)
By: David Cuartielles, Andreas Göransson, Eric Foster-Johnson

Overview of this book

Java is a versatile, popular programming language used across a wide range of industries. Learning how to write effective Java code can take your career to the next level, and The Java Workshop will help you do just that. This book is designed to take the pain out of Java coding and teach you everything you need to know to be productive in building real-world software. The Workshop starts by showing you how to use classes, methods, and the built-in Collections API to manipulate data structures effortlessly. You’ll dive right into learning about object-oriented programming by creating classes and interfaces and making use of inheritance and polymorphism. After learning how to handle exceptions, you’ll study the modules, packages, and libraries that help you organize your code. As you progress, you’ll discover how to connect to external databases and web servers, work with regular expressions, and write unit tests to validate your code. You’ll also be introduced to functional programming and see how to implement it using lambda functions. By the end of this Workshop, you’ll be well-versed with key Java concepts and have the knowledge and confidence to tackle your own ambitious projects with Java.
Table of Contents (20 chapters)

Introduction

On an operating system level, files and directories are kind of similar. They are names representing a link to something in storage, whether it is your hard drive, somewhere in the cloud, or the USB drive in your pocket. However, at a conceptual level, they are inherently different. Files contain information, while directories link to other directories and files.

There are two main Application Programming Interface (APIs) that deal with the data: java.io and java.nio. Both APIs can be used to navigate directories and manipulate files. The information about the location of a file is called a pathname. It contains the full information of the directory in your hard drive in which the file resides, all the way to the file's name and extension. It should have the following form:

/folder_1/folder_2/[...]/folder_n/file.extension

Different operating systems refer to files and folder structures differently. In Unix systems (such as Linux or macOSX), the / symbol represents...