Skip to content

Instantly share code, notes, and snippets.

@adambgoode
Created April 17, 2018 18:02
Show Gist options
  • Save adambgoode/57ad0486206702d747b63b344a56b24d to your computer and use it in GitHub Desktop.
Save adambgoode/57ad0486206702d747b63b344a56b24d to your computer and use it in GitHub Desktop.
JShell sample: work with directories and files
// 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