Created
April 17, 2018 18:02
-
-
Save adambgoode/57ad0486206702d747b63b344a56b24d to your computer and use it in GitHub Desktop.
JShell sample: work with directories and files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create and delete directories | |
// Usage: jshell --class-path ../libs/commons-io.jar work-with-directories.jsh | |
import org.apache.commons.io.FileUtils | |
String content = "JShell Scripting" | |
File file = new File("test.txt") | |
// Create text file | |
FileUtils.writeStringToFile(file, content) | |
// Move text file to newly created folder | |
File folder = new File("folder") | |
FileUtils.moveToDirectory(file, folder, true) | |
// Delete the new Folder again | |
FileUtils.deleteDirectory(folder) | |
/exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment