本文整理汇总了Java中org.apache.commons.vfs.VFS类的典型用法代码示例。如果您正苦于以下问题:Java VFS类的具体用法?Java VFS怎么用?Java VFS使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VFS类属于org.apache.commons.vfs包,在下文中一共展示了VFS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.apache.commons.vfs.VFS; //导入依赖的package包/类
protected void setUp() throws Exception
{
String tempDir = System.getProperty("java.io.tmpdir");
FileSystemManager fsm = VFS.getManager();
rootDir = fsm.resolveFile(tempDir + "/testfsr");
rootDir.createFolder();
tempFile = createFile(rootDir, "fsp.html");
subdir1 = fsm.resolveFile(rootDir, "SubDir1");
subdir1.createFolder();
createFile(subdir1, "toto.html");
createFile(subdir1, "titi.HTML");
subdir2 = fsm.resolveFile(rootDir, "SubDir2");
subdir2.createFolder();
createFile(subdir2, "toto.html");
subsubdir = fsm.resolveFile(subdir2, "subsubdir");
subsubdir.createFolder();
createFile(subsubdir, "momo.html");
createFile(subsubdir, "mimi.html");
}
示例2: getInitialBaseDir
import org.apache.commons.vfs.VFS; //导入依赖的package包/类
@Override
public FileObject getInitialBaseDir(FtpSession session)
{
String expr = "/ftpd/user[@name=\""+session.getUsername()+"\"]/basedir/text()";
String dirStr = evalXPath(expr);
if(StringUtils.isEmpty(dirStr))
{
dirStr = evalXPath("/ftpd/default/basedir/text()");
}
if(StringUtils.isEmpty(dirStr) )
throw new IncorrectConfigurationException("Basedir is not set");
try
{
FileSystemManager fsManager = VFS.getManager();
return fsManager.resolveFile(dirStr);
}
catch (FileSystemException e)
{
throw new IncorrectConfigurationException(e);
}
}
示例3: getInitialCurrentDir
import org.apache.commons.vfs.VFS; //导入依赖的package包/类
@Override
public FileObject getInitialCurrentDir(FtpSession session)
{
String expr = "/ftpd/user[@name=\""+session.getUsername()+"\"]/initialdir/text()";
String dirStr = evalXPath(expr);
if(StringUtils.isEmpty(dirStr))
{
dirStr = evalXPath("/ftpd/default/initialdir/text()");
}
if(StringUtils.isEmpty(dirStr))
return getInitialBaseDir(session);
try
{
FileSystemManager fsManager = VFS.getManager();
return fsManager.resolveFile(dirStr);
}
catch (FileSystemException e)
{
throw new IncorrectConfigurationException(e);
}
}
示例4: KettleVFS
import org.apache.commons.vfs.VFS; //导入依赖的package包/类
private KettleVFS()
{
// Install a shutdown hook to make sure that the file system manager is closed
// This will clean up temporary files in vfs_cache
//
Thread thread = new Thread(new Runnable(){
public void run() {
try
{
FileSystemManager mgr = VFS.getManager();
if (mgr instanceof DefaultFileSystemManager)
{
((DefaultFileSystemManager)mgr).close();
}
}
catch (FileSystemException e)
{
e.printStackTrace();
}
}
});
Runtime.getRuntime().addShutdownHook(thread);
}
示例5: testDefaultInstance
import org.apache.commons.vfs.VFS; //导入依赖的package包/类
/**
* Sanity test.
*/
public void testDefaultInstance() throws Exception
{
// Locate the default manager
final FileSystemManager manager = VFS.getManager();
// Lookup a test jar file
final File jarFile = getTestResource("test.jar");
FileObject file = manager.toFileObject(jarFile);
assertNotNull(file);
assertTrue(file.exists());
assertSame(FileType.FILE, file.getType());
// Expand it
file = manager.createFileSystem(file);
assertNotNull(file);
assertTrue(file.exists());
assertSame(FileType.FOLDER, file.getType());
}
示例6: testCeateFile
import org.apache.commons.vfs.VFS; //导入依赖的package包/类
/**
* 특정 위치에 파일을 생성하고 필요에 따라 생성한 파일을 캐싱한다.
* @throws Exception
*/
@Test
public void testCeateFile() throws Exception {
FileSystemManager manager = VFS.getManager();
FileObject baseDir = manager.resolveFile(System.getProperty("user.dir"));
final FileObject file = manager.resolveFile(baseDir, "testfolder/file1.txt");
// 모든 파일 삭제
file.delete(Selectors.SELECT_FILES);
assertFalse(file.exists());
// 파일 생성
file.createFile();
assertTrue(file.exists());
}
示例7: testCaching3
import org.apache.commons.vfs.VFS; //导入依赖的package包/类
@Test
public void testCaching3() throws Exception {
FileSystemManager manager = VFS.getManager();
String testFolder = "d:/workspace/java/e-gov/eGovFramework/RTE/DEV/trunk/Foundation/egovframework.rte.fdl.filehandling/test";
FileObject scratchFolder = manager.resolveFile(testFolder);
// releaseable
FileObject dir1 = scratchFolder.resolveFile("file1.txt");
// avoid cache removal
FileObject dir2 = scratchFolder.resolveFile("file2.txt");
dir2.getContent();
// check if the cache still holds the right instance
FileObject dir2_2 = scratchFolder.resolveFile("file2.txt");
assertTrue(dir2 == dir2_2);
// check if the cache still holds the right instance
/* FileObject dir1_2 = scratchFolder.resolveFile("file1.txt");
assertFalse(dir1 == dir1_2);*/
}
示例8: VFSRepository
import org.apache.commons.vfs.VFS; //导入依赖的package包/类
/**
* <p>Constructor for VFSRepository.</p>
*/
public VFSRepository()
{
try
{
fileSystemManager = VFS.getManager();
}
catch (FileSystemException ex)
{
throw ExceptionImposter.imposterize( ex );
}
}
示例9: createFile
import org.apache.commons.vfs.VFS; //导入依赖的package包/类
private FileObject createFile(FileObject directory, String fileName) throws Exception
{
FileObject f = VFS.getManager().resolveFile(directory, fileName);
OutputStream os = f.getContent().getOutputStream();
os.write(TestStringSpecifications.SimpleAlternateCalculatorTest
.getBytes());
os.close();
return f;
}
示例10: getFileSystemManager
import org.apache.commons.vfs.VFS; //导入依赖的package包/类
/** Get the FileSystemManager.
@return The FileSystemManager
@throws FileSystemException
*/
public synchronized FileSystemManager getFileSystemManager()
throws FileSystemException{
if(fileSystemManager == null){
fileSystemManager = VFS.getManager();
}
return fileSystemManager;
}
示例11: JavaFileIO
import org.apache.commons.vfs.VFS; //导入依赖的package包/类
public JavaFileIO(ServletConfig config) throws ServletException{
try {
fsManager = VFS.getManager();
((StandardFileSystemManager)fsManager).addProvider( "s3", new com.intridea.io.vfs.provider.s3.S3FileProvider() );
((StandardFileSystemManager)fsManager).addOperationProvider("s3", new com.intridea.io.vfs.provider.s3.acl.AclOperationsProvider() );
} catch (Exception e1) {
cfEngine.log("Failed to register the s3:// name space: " + e1.getMessage());
}
// Set the working directory
try {
if (!setWorkingDirectory(config.getInitParameter("BLUEDRAGON_WORKING_DIRECTORY"))) {
throw new Exception(config.getInitParameter("BLUEDRAGON_WORKING_DIRECTORY") + " could not be created");
}
} catch (Exception E) {
System.out.println( cfEngine.PRODUCT_NAME + ": Init Parameter BLUEDRAGON_WORKING_DIRECTORY Error: " + E);
throw new ServletException( cfEngine.PRODUCT_NAME + ": Init Parameter BLUEDRAGON_WORKING_DIRECTORY Error: " + E);
}
// Setup the logging
com.nary.Debug.SystemOff();
File logFile = new File( getWorkingDirectory(), "bluedragon.log");
rolloverLogFile(logFile);
com.nary.Debug.setFilename(logFile.toString());
setTempDirectory();
setupRuntimeLogging();
cfEngine.log(cfEngine.PRODUCT_NAME + " WorkingDirectory=[" + getWorkingDirectory() + "]");
cfEngine.log(cfEngine.PRODUCT_NAME + " TempDirectory=[" + getTempDirectory() + "]");
}
示例12: getInitialBaseDir
import org.apache.commons.vfs.VFS; //导入依赖的package包/类
@Override
public FileObject getInitialBaseDir(FtpSession session)
{
String baseDirStr = System.getProperty(BASE_DIR_PROPERTY);
if(baseDirStr==null) throw new IncorrectConfigurationException("Base dir is not specified");
try
{
FileSystemManager fsManager = VFS.getManager();
return fsManager.resolveFile(baseDirStr);
}
catch (FileSystemException e)
{
throw new IncorrectConfigurationException(e);
}
}
示例13: setUp
import org.apache.commons.vfs.VFS; //导入依赖的package包/类
protected void setUp() throws Exception {
super.setUp();
FileSystemManager fsm = VFS.getManager();
FileObject fsRoot = fsm.createVirtualFileSystem(fsm.resolveFile("ram:/"));
aFile = fsRoot.resolveFile("/file.txt");
aFile.delete();
aFile.createFile();
aDirectory = fsRoot.resolveFile("/folder");
aDirectory.delete();
aDirectory.createFolder();
}
示例14: explodeJar
import org.apache.commons.vfs.VFS; //导入依赖的package包/类
/**
* "Deploys" the plugin jar file.
*
* @param parent
* @return
* @throws FileSystemException
*/
private FileObject explodeJar(FileObject parent) throws FileSystemException
{
// By Alex, 7/13/07
// Since the JVM does not support nested jars and
// URLClassLoaders, we have to hack it
// see
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4735639
//
// We do so by exploding the jar, sort of like deploying it
FileObject dest = VFS.getManager().resolveFile(Const.getKettleDirectory() + File.separator + WORK_DIR);
dest.createFolder();
FileObject destFile = dest.resolveFile(parent.getName().getBaseName());
if (!destFile.exists())
destFile.createFolder();
else
// delete children
for (FileObject child : destFile.getChildren())
child.delete(new AllFileSelector());
// force VFS to treat it as a jar file explicitly with children,
// etc. and copy
destFile.copyFrom(!(parent instanceof JarFileObject) ? VFS.getManager().resolveFile(
JAR + ":" + parent.getName().getURI()) : parent, new AllFileSelector());
return destFile;
}
示例15: SingleBloomDataFilterVfsTest
import org.apache.commons.vfs.VFS; //导入依赖的package包/类
public SingleBloomDataFilterVfsTest() throws FileSystemException, KettleFileException
{
folder = VFS.getManager().resolveFile(getParameter("provider.uri.vfs", "tmp://ic-filter/") + System.currentTimeMillis());
provider = new VfsFilterProvider(folder.getURL().toString());
config.withFilterFileName("single_filter_" + System.currentTimeMillis());
}