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 FileObject
private final FileSystemManager
private final BufferedReader
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Does a 'cat' command.private void
Does a 'cd' command.private void
Does a 'cp' command.private static String
getVersion
(Class<?> cls) private void
go()
private void
handleCommand
(String[] cmd) Handles a command.private void
help()
Does a 'help' command.private void
private void
private void
listChildren
(FileObject dir, boolean recursive, String prefix) Lists the children of a folder.private void
Does an 'ls' command.static void
private String[]
Returns the next command, split into tokens.private void
pwd()
Does a 'pwd' command.private void
pwfs()
Does a 'pwfs' command.private void
Does an 'rm' command.private void
Does 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
-