Example usage for org.apache.commons.vfs2 VFS getManager

List of usage examples for org.apache.commons.vfs2 VFS getManager

Introduction

In this page you can find the example usage for org.apache.commons.vfs2 VFS getManager.

Prototype

public static synchronized FileSystemManager getManager() throws FileSystemException 

Source Link

Document

Returns the default FileSystemManager instance.

Usage

From source file:nkfust.selab.android.explorer.layout.view.PhotoFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        path = savedInstanceState.getString(PATH);
    }/*  www  . j a v  a  2 s.com*/

    DisplayMetrics dm = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
    try {
        FileObject cache = VFS.getManager().resolveFile(getActivity().getExternalCacheDir().getPath());
        aFetcher = new ImageFetcher(getActivity(), (int) (dm.widthPixels), (int) (dm.heightPixels), cache);
        aFetcher.setImageCache(new ImageCache(getActivity(), cache));
    } catch (FileSystemException e) {
        e.printStackTrace();
    }
}

From source file:nl.b3p.kaartenbalie.service.MapFileScanner.java

public void contextInitialized(ServletContextEvent sce) {
    try {/*from   w w  w .  ja  v  a2 s  .  c  o m*/
        this.context = sce.getServletContext();
        init();

        fsManager = VFS.getManager();

        listendir = fsManager.resolveFile(scandirectory);
        fm = new DefaultFileMonitor(new MapFileListener(organization));
        fm.setRecursive(true);
        fm.addFile(listendir);
        fm.start();

    } catch (FileSystemException ex) {
        log.error("Cannot initialize MapFileScanner: ", ex);
    }
}

From source file:org.apache.commons.vfs2.example.ChangeLastModificationTime.java

public static void main(final String[] args) throws Exception {
    if (args.length == 0) {
        System.err.println("Please pass the name of a file as parameter.");
        return;//w ww .  j av a  2  s  .c  om
    }

    final FileObject fo = VFS.getManager().resolveFile(args[0]);
    final long setTo = System.currentTimeMillis();
    System.err.println("set to: " + setTo);
    fo.getContent().setLastModifiedTime(setTo);
    System.err.println("after set: " + fo.getContent().getLastModifiedTime());
}

From source file:org.apache.commons.vfs2.example.Shell.java

private Shell() throws IOException {
    mgr = VFS.getManager();
    cwd = mgr.toFileObject(new File(System.getProperty("user.dir")));
    reader = new BufferedReader(new InputStreamReader(System.in, Charset.defaultCharset()));
}

From source file:org.apache.commons.vfs2.example.ShowProperties.java

public static void main(final String[] args) {
    if (args.length == 0) {
        System.err.println("Please pass the name of a file as parameter.");
        System.err.println("e.g. java org.apache.commons.vfs2.example.ShowProperties LICENSE.txt");
        return;//from ww w .jav  a  2s. com
    }
    for (final String arg : args) {
        try {
            final FileSystemManager mgr = VFS.getManager();
            System.out.println();
            System.out.println("Parsing: " + arg);
            final FileObject file = mgr.resolveFile(arg);
            System.out.println("URL: " + file.getURL());
            System.out.println("getName(): " + file.getName());
            System.out.println("BaseName: " + file.getName().getBaseName());
            System.out.println("Extension: " + file.getName().getExtension());
            System.out.println("Path: " + file.getName().getPath());
            System.out.println("Scheme: " + file.getName().getScheme());
            System.out.println("URI: " + file.getName().getURI());
            System.out.println("Root URI: " + file.getName().getRootURI());
            System.out.println("Parent: " + file.getName().getParent());
            System.out.println("Type: " + file.getType());
            System.out.println("Exists: " + file.exists());
            System.out.println("Readable: " + file.isReadable());
            System.out.println("Writeable: " + file.isWriteable());
            System.out.println("Root path: " + file.getFileSystem().getRoot().getName().getPath());
            if (file.exists()) {
                if (file.getType().equals(FileType.FILE)) {
                    System.out.println("Size: " + file.getContent().getSize() + " bytes");
                } else if (file.getType().equals(FileType.FOLDER) && file.isReadable()) {
                    final FileObject[] children = file.getChildren();
                    System.out.println("Directory with " + children.length + " files");
                    for (int iterChildren = 0; iterChildren < children.length; iterChildren++) {
                        System.out.println("#" + iterChildren + ": " + children[iterChildren].getName());
                        if (iterChildren > SHOW_MAX) {
                            break;
                        }
                    }
                }
                System.out.println("Last modified: "
                        + DateFormat.getInstance().format(new Date(file.getContent().getLastModifiedTime())));
            } else {
                System.out.println("The file does not exist");
            }
            file.close();
        } catch (final FileSystemException ex) {
            ex.printStackTrace();
        }
    }
}

From source file:org.apache.hadoop.gateway.topology.file.FileTopologyProvider.java

public FileTopologyProvider(File directory) throws IOException, SAXException {
    this(null, VFS.getManager().toFileObject(directory));
}

From source file:org.apache.hadoop.gateway.topology.file.FileTopologyProviderTest.java

private FileObject createDir(String name) throws FileSystemException {
    FileSystemManager fsm = VFS.getManager();
    FileObject dir = fsm.resolveFile(name);
    dir.createFolder();//from  www.j  ava  2  s.c om
    assertTrue("Failed to create test dir " + dir.getName().getFriendlyURI(), dir.exists());
    return dir;
}

From source file:org.apache.nifi.processors.pcap.SplitPcap.java

@OnScheduled
public void setup() {
    try {//from  w  w  w. j  a v a 2s.  c  o m
        vfsManager = VFS.getManager();
    } catch (FileSystemException e) {
        throw new ProcessException("Could not get the VFS manager", e);
    }
}

From source file:org.apache.olingo.fit.utils.FSManager.java

private FSManager() throws IOException {
    fsManager = VFS.getManager();

    final FileObject basePath = fsManager
            .resolveFile(RES_PREFIX + File.separatorChar + ODataServiceVersion.V40.name());
    final String absoluteBaseFolder = basePath.getURL().getPath();

    for (FileObject fo : find(basePath, null)) {
        if (fo.getType() == FileType.FILE && !fo.getName().getBaseName().contains("Metadata")
                && !fo.getName().getBaseName().contains("metadata")) {
            final String path = fo.getURL().getPath().replace(absoluteBaseFolder,
                    "//" + ODataServiceVersion.V40.name());
            putInMemory(fo.getContent().getInputStream(), path);
        }//ww  w. j  a  v a  2  s  . c  om
    }
}

From source file:org.apache.river.container.FileUtilityImpl.java

@Init
public void init() throws FileSystemException {
    fsm = VFS.getManager();
}