当前位置: 首页>>代码示例>>Java>>正文


Java LocalFile类代码示例

本文整理汇总了Java中org.apache.commons.vfs2.provider.local.LocalFile的典型用法代码示例。如果您正苦于以下问题:Java LocalFile类的具体用法?Java LocalFile怎么用?Java LocalFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LocalFile类属于org.apache.commons.vfs2.provider.local包,在下文中一共展示了LocalFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: actionPerformed

import org.apache.commons.vfs2.provider.local.LocalFile; //导入依赖的package包/类
public void actionPerformed(ActionEvent e)
{
    VFSJFileChooser fc = getFileChooser();
    FileObject currentDir = fc.getCurrentDirectoryObject();

    if (currentDir instanceof LocalFile)
    {
        changeDirectory(fc.getFileSystemView().getHomeDirectory());
    }
    else
    {
        try
        {
            changeDirectory(fc.getCurrentDirectoryObject().getFileSystem()
                              .getRoot());
        }
        catch (FileSystemException ex)
        {
            Logger.getLogger(BasicVFSFileChooserUI.class.getName())
                  .log(Level.SEVERE, null, ex);
        }
    }
}
 
开发者ID:fracpete,项目名称:vfsjfilechooser2,代码行数:24,代码来源:BasicVFSFileChooserUI.java

示例2: getRoots

import org.apache.commons.vfs2.provider.local.LocalFile; //导入依赖的package包/类
/**
 * Returns all root partitions on this system. For example, on
 * Windows, this would be the "Desktop" folder, while on DOS this
 * would be the A: through Z: drives.
 * @param fo
 * @return
 */
@Override
public FileObject[] getRoots(FileObject fo) {
    if (fo instanceof DecoratedFileObject)
        fo = ((DecoratedFileObject) fo).getDecoratedFileObject();

    try {
        if (fo instanceof LocalFile) {
            File[] roots = File.listRoots();
            FileObject[] localRoots = new FileObject[roots.length];
            for (int i = 0; i < roots.length; i++)
                localRoots[i] = fileSystemManager.toFileObject(roots[i]);
            return localRoots;
        } // Don't cache this array, because filesystem might change
        else {
            FileObject p = fo.getFileSystem().getRoot();
            return new FileObject[]{p};
        }
    } catch (FileSystemException e) {
        return EMPTY;
    }
}
 
开发者ID:shevek,项目名称:vfsjfilechooser,代码行数:29,代码来源:CommonsVfs2FileSystemView.java

示例3: system

import org.apache.commons.vfs2.provider.local.LocalFile; //导入依赖的package包/类
@Primitive("system")
public static SEXP system(@Current Context context, String command, int flag, SEXP stdin, SEXP stdout, SEXP stderr) throws IOException, InterruptedException {
  boolean invisible = (flag >= 20 && flag < 29);
  boolean minimized = (flag >= 10 && flag < 19);
  
  List<String> args = parseArgs(command);
  ProcessBuilder builder = new ProcessBuilder(args);
  
  FileObject workingDir = context.getSession().getWorkingDirectory();
  if(workingDir instanceof LocalFile) {
    File localDir = new File(workingDir.getURL().getFile());
    builder.directory(localDir);
  }
  Process process = builder.start();
  process.waitFor();
  
  int exitValue = process.exitValue();
  return new IntArrayVector(exitValue);
}
 
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:20,代码来源:System.java

示例4: localFile

import org.apache.commons.vfs2.provider.local.LocalFile; //导入依赖的package包/类
@Override public File localFile(FileObject resource, FileObject dir) {
    if(resource instanceof LocalFile) {
        return FileUtils.toFile(resource);
    }

    final File localDir = localPath(dir);
    if(localDir == null) {
        throw new MetaborgRuntimeException("Replication directory " + dir
            + " is not on the local filesystem, cannot get local file for " + resource);
    }
    try {
        dir.createFolder();

        final FileObject copyLoc;
        if(resource.getType() == FileType.FOLDER) {
            copyLoc = dir;
        } else {
            copyLoc = dir.resolveFile(resource.getName().getBaseName());
        }
        copyLoc.copyFrom(resource, new AllFileSelector());

        return localDir;
    } catch(FileSystemException e) {
        throw new MetaborgRuntimeException("Could not get local file for " + resource, e);
    }
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:27,代码来源:ResourceService.java

示例5: isLocal

import org.apache.commons.vfs2.provider.local.LocalFile; //导入依赖的package包/类
public static boolean isLocal(FileObject f)
{
	if (f instanceof OnCallRefreshFileObject)
		try
		{
			return f.getContent().getFile() instanceof LocalFile;
		}
		catch (FileSystemException e)
		{
			e.printStackTrace();
		}
	return f instanceof LocalFile;
}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:14,代码来源:VFSUtils.java

示例6: getLocalFile

import org.apache.commons.vfs2.provider.local.LocalFile; //导入依赖的package包/类
/**
 * Returns the local java.io.File representing this stored file or directory. Be careful
 * to use this only for reading data, do never modify directly!
 * 
 * @return the file in the local filesystem representing this file
 */
public File getLocalFile() throws IOException {
    if (fo instanceof LocalFile) {
        return new File(fo.getURL().getPath());
    } else {
        return null;
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:14,代码来源:MCRStoredNode.java

示例7: download

import org.apache.commons.vfs2.provider.local.LocalFile; //导入依赖的package包/类
@Override
public void download(String remotePath, Path local) throws IOException {
    LocalFile localFileObject = (LocalFile) fileSystemManager.resolveFile(local.toUri().toString());
    FileObject remoteFileObject = remoteRootDirectory.resolveFile(remotePath);
    try {
        localFileObject.copyFrom(remoteFileObject, new AllFileSelector());
    } finally {
        localFileObject.close();
        remoteFileObject.close();
    }

}
 
开发者ID:sparsick,项目名称:comparison-java-ssh-libs,代码行数:13,代码来源:VfsSftpClient.java

示例8: upload

import org.apache.commons.vfs2.provider.local.LocalFile; //导入依赖的package包/类
@Override
public void upload(Path local, String remotePath) throws IOException {
    LocalFile localFileObject = (LocalFile) fileSystemManager.resolveFile(local.toUri().toString());
    FileObject remoteFileObject = remoteRootDirectory.resolveFile(remotePath);
    try {
        remoteFileObject.copyFrom(localFileObject, new AllFileSelector());
    } finally {
        localFileObject.close();
        remoteFileObject.close();
    }
}
 
开发者ID:sparsick,项目名称:comparison-java-ssh-libs,代码行数:12,代码来源:VfsSftpClient.java

示例9: getRoots

import org.apache.commons.vfs2.provider.local.LocalFile; //导入依赖的package包/类
/**
 * Returns all root partitions on this system. For example, on
 * Windows, this would be the "Desktop" folder, while on DOS this
 * would be the A: through Z: drives.
 * @param fo
 * @return
 */
public FileObject[] getRoots(FileObject fo)
{
    if (fo instanceof DecoratedFileObject)
    {
        fo = ((DecoratedFileObject) fo).getDecoratedFileObject();
    }

    if (fo instanceof LocalFile)
    {
        File[] roots = File.listRoots();
        final int count = roots.length;
        localRoots = new FileObject[roots.length];

        for (int i = 0; i < count; i++)
        {
            localRoots[i] = VFSUtils.toFileObject(roots[i]);
        }

        return localRoots.clone();
    }

    // Don't cache this array, because filesystem might change
    else
    {
        FileObject p = VFSUtils.getRootFileSystem(fo);

        return new FileObject[] { p };
    }
}
 
开发者ID:fracpete,项目名称:vfsjfilechooser2,代码行数:37,代码来源:AbstractVFSFileSystemView.java

示例10: toFile

import org.apache.commons.vfs2.provider.local.LocalFile; //导入依赖的package包/类
/**
 * Converts (if possible) a {@link FileObject} to a {@link File}. Use with
 * caution since {@link FileObject} is generally preferred.
 *
 * @param fileObject
 * @return
 */
public static File toFile(final FileObject fileObject) {
    if (fileObject instanceof LocalFile) {
        final Method method = ReflectionUtils.getMethod(LocalFile.class, "getLocalFile");
        try {
            method.setAccessible(true);
            final Object result = method.invoke(fileObject);
            return (File) result;
        } catch (final Exception e) {
            throw new IllegalStateException(e);
        }
    }
    return null;
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:21,代码来源:VFSUtils.java

示例11: toFile

import org.apache.commons.vfs2.provider.local.LocalFile; //导入依赖的package包/类
/**
 * Converts (if possible) a {@link FileObject} to a {@link File}. Use with
 * caution since {@link FileObject} is generally preferred.
 * 
 * @param fileObject
 * @return
 */
public static File toFile(FileObject fileObject) {
    if (fileObject instanceof LocalFile) {
        Method method = ReflectionUtils.getMethod(LocalFile.class, "getLocalFile");
        try {
            method.setAccessible(true);
            Object result = method.invoke(fileObject);
            return (File) result;
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
    }
    return null;
}
 
开发者ID:datacleaner,项目名称:AnalyzerBeans,代码行数:21,代码来源:VFSUtils.java

示例12: PoiWorkbook

import org.apache.commons.vfs2.provider.local.LocalFile; //导入依赖的package包/类
public PoiWorkbook( String filename, String encoding ) throws KettleException {
  this.filename = filename;
  this.encoding = encoding;
  this.log = KettleLogStore.getLogChannelInterfaceFactory().create( this );
  try {
    FileObject fileObject = KettleVFS.getFileObject( filename );
    if ( fileObject instanceof LocalFile ) {
      // This supposedly shaves off a little bit of memory usage by allowing POI to randomly access data in the file
      //
      String localFilename = KettleVFS.getFilename( fileObject );
      File excelFile = new File( localFilename );
      try {
        npoifs = new NPOIFSFileSystem( excelFile );
        workbook = org.apache.poi.ss.usermodel.WorkbookFactory.create( npoifs );
      } catch ( Exception ofe ) {
        try {
          opcpkg = OPCPackage.open( excelFile );
          workbook = org.apache.poi.ss.usermodel.WorkbookFactory.create( opcpkg );
        } catch ( Exception ex ) {
          workbook = org.apache.poi.ss.usermodel.WorkbookFactory.create( excelFile );
        }
      }
    } else {
      internalIS = KettleVFS.getInputStream( filename );
      workbook = org.apache.poi.ss.usermodel.WorkbookFactory.create( internalIS );
    }
  } catch ( Exception e ) {
    throw new KettleException( e );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:31,代码来源:PoiWorkbook.java

示例13: getOutputStream

import org.apache.commons.vfs2.provider.local.LocalFile; //导入依赖的package包/类
public static OutputStream getOutputStream( FileObject fileObject, boolean append ) throws IOException {
  FileObject parent = fileObject.getParent();
  if ( parent != null ) {
    if ( !parent.exists() ) {
      throw new IOException( BaseMessages.getString(
        PKG, "KettleVFS.Exception.ParentDirectoryDoesNotExist", getFriendlyURI( parent ) ) );
    }
  }
  try {
    fileObject.createFile();
    FileContent content = fileObject.getContent();
    return content.getOutputStream( append );
  } catch ( FileSystemException e ) {
    // Perhaps if it's a local file, we can retry using the standard
    // File object. This is because on Windows there is a bug in VFS.
    //
    if ( fileObject instanceof LocalFile ) {
      try {
        String filename = getFilename( fileObject );
        return new FileOutputStream( new File( filename ), append );
      } catch ( Exception e2 ) {
        throw e; // throw the original exception: hide the retry.
      }
    } else {
      throw e;
    }
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:29,代码来源:KettleVFS.java

示例14: getFileInputStream

import org.apache.commons.vfs2.provider.local.LocalFile; //导入依赖的package包/类
/**
 * Get a FileInputStream for a local file. Local files can be read with NIO.
 *
 * @param fileObject
 * @return a FileInputStream
 * @throws IOException
 * @deprecated because of API change in Apache VFS. As a workaround use FileObject.getName().getPathDecoded(); Then
 *             use a regular File() object to create a File Input stream.
 */
@Deprecated
public static FileInputStream getFileInputStream( FileObject fileObject ) throws IOException {

  if ( !( fileObject instanceof LocalFile ) ) {
    // We can only use NIO on local files at the moment, so that's what we limit ourselves to.
    //
    throw new IOException( BaseMessages.getString( PKG, "FixedInput.Log.OnlyLocalFilesAreSupported" ) );
  }

  return new FileInputStream( fileObject.getName().getPathDecoded() );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:21,代码来源:KettleVFS.java

示例15: localPath

import org.apache.commons.vfs2.provider.local.LocalFile; //导入依赖的package包/类
@Override public File localPath(FileObject resource) {
    if(resource instanceof LocalFile) {
        return FileUtils.toFile(resource);
    }
    return null;
}
 
开发者ID:metaborg,项目名称:spoofax,代码行数:7,代码来源:ResourceService.java


注:本文中的org.apache.commons.vfs2.provider.local.LocalFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。