public class UserFileAccess extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BUFFERSIZE
default file read/write buffersize in bytes
|
| Constructor and Description |
|---|
UserFileAccess(FileAccess fa,
String userID,
String groupID) |
| Modifier and Type | Method and Description |
|---|---|
void |
asUser(Runnable runnable)
run the given task as the current user
|
String |
getHome()
gets the user's home directory
|
RandomAccessFile |
getRandomAccessFile(File file,
String mode)
create a
RandomAccessFile for accessing the given path |
FileInfo[] |
listFiles(File directory)
lists files in the given directory
|
void |
mkdir(String canonicalPath)
create a directory.
|
InputStream |
readFile(String canonicalPath,
int bufferSize)
create a
InputStream for reading |
void |
rm(String canonicalPath)
delete a file or directory
|
void |
setUser(String canonicalPath)
set user/group on the given file
|
FileInfo |
stat(String path)
get info on a single file
|
OutputStream |
writeFile(String canonicalPath,
boolean append,
int bufferSize)
create a
OutputStream for writing |
public static final int DEFAULT_BUFFERSIZE
public UserFileAccess(FileAccess fa, String userID, String groupID)
public InputStream readFile(String canonicalPath, int bufferSize) throws Exception
InputStream for readingcanonicalPath - - the canonical path to the filebufferSize - - the buffer size for reading fromInputStreamExceptionpublic RandomAccessFile getRandomAccessFile(File file, String mode) throws IOException
RandomAccessFile for accessing the given pathfile - - the pathmode - - the mode (see RandomAccessFile.RandomAccessFile(java.io.File, String)IOExceptionExceptionpublic FileInfo[] listFiles(File directory)
parent - - the parent fileFileInfo objectspublic OutputStream writeFile(String canonicalPath, boolean append, int bufferSize) throws Exception
OutputStream for writingcanonicalPath - - the canonical path to the filebufferSize - - the buffer size for writing to diskOutputStreamExceptionpublic void setUser(String canonicalPath) throws Exception
canonicalPath - Exceptionpublic void mkdir(String canonicalPath) throws Exception
canonicalPath - - the directory to createExceptionpublic void rm(String canonicalPath) throws Exception
canonicalPath - - the file/directory to deleteExceptionpublic String getHome()
ExceptionCopyright © 2010–2016 UNICORE. All rights reserved.