课程: Java: Advanced Concepts for High-Performance Development
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Working with files in Java - Java教程
课程: Java: Advanced Concepts for High-Performance Development
Working with files in Java
- [Instructor] Java has always had ways to handle files right from the very first version. There are two different packages that contain classes that we can use to work with files, java.io and java.nio. There is a class called file in the java.io package and that can be used to do things like create new files and list files in a directory. This class has been around since the beginning, and it's unlikely to be deprecated because it's been used so much, but it does have a few drawbacks. These drawbacks are addressed by the classes in the java.nio package. This introduced some new classes such as Path, Paths, and Files. These classes give us a newer API that can do everything the file class can do but has better support for things like error handling. So in general, it's a better option to go with the classes in java.nio for working with files. And because of these improvements, I'll be using the classes in the…