课程: Java: Advanced Concepts for High-Performance Development
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Copying files in Java - Java教程
课程: Java: Advanced Concepts for High-Performance Development
Copying files in Java
- [Instructor] Let's see how we can copy files in Java now. So in this example, inside 07 04, I've actually got a directory called files and inside that I have two more directories, A and B. Inside example dot TXT, I've just got the words, hello world. So to copy this file, I'm going to open up the class called file copier, which just contains an empty main method. And inside here, I'm going to create a path object which is going to say what the path to the file I want to copy is. So I'm going to say path and let IntelliJ add the import statement for me. And then I'm going to call this path, in fact, I'll call it path to file and I'll say equals. And then I'm going to call the static get method from the paths class. So I'm going to say paths and again that will add the import for me and I'm going to say get and then I just pass in the path to the file I want to copy. So I'm going to say source slash main slash java…