Package org.apache.commons.vfs2.example
Class Shell
java.lang.Object
org.apache.commons.vfs2.example.Shell
A simple command-line shell for performing file operations.
See Commons VFS Shell Examples in Apache Commons Wiki.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate FileObjectprivate final FileSystemManagerprivate final BufferedReader -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidDoes a 'cat' command.private voidDoes a 'cd' command.private voidDoes a 'cp' command.private static StringgetVersion(Class<?> cls) private voidgo()private voidhandleCommand(String[] cmd) Handles a command.private voidhelp()Does a 'help' command.private voidprivate voidprivate voidlistChildren(FileObject dir, boolean recursive, String prefix) Lists the children of a folder.private voidDoes an 'ls' command.static voidprivate String[]Returns the next command, split into tokens.private voidpwd()Does a 'pwd' command.private voidpwfs()Does a 'pwfs' command.private voidDoes an 'rm' command.private voidDoes a 'touch' command.
-
Field Details
-
mgr
-
cwd
-
reader
-
-
Constructor Details
-
Shell
- Throws:
IOException
-
-
Method Details
-
main
-
go
- Throws:
Exception
-
handleCommand
Handles a command.- Throws:
Exception
-
info
- Throws:
Exception
-
info
- Throws:
Exception
-
help
private void help()Does a 'help' command. -
rm
Does an 'rm' command.- Throws:
Exception
-
cp
Does a 'cp' command.- Throws:
Exception
-
cat
Does a 'cat' command.- Throws:
Exception
-
pwd
private void pwd()Does a 'pwd' command. -
pwfs
private void pwfs()Does a 'pwfs' command. -
cd
Does a 'cd' command. If the taget directory does not exist, a message is printed toSystem.err.- Throws:
Exception
-
ls
Does an 'ls' command.- Throws:
FileSystemException
-
touch
Does a 'touch' command.- Throws:
Exception
-
listChildren
private void listChildren(FileObject dir, boolean recursive, String prefix) throws FileSystemException Lists the children of a folder.- Throws:
FileSystemException
-
nextCommand
Returns the next command, split into tokens.- Throws:
IOException
-
getVersion
-