List of usage examples for org.apache.commons.vfs2 FileObject getName
FileName getName();
From source file:binky.reportrunner.engine.utils.impl.FileSystemHandlerImpl.java
public String getFileName(String url) throws IOException { FileObject file = fsManager.resolveFile(url); return file.getName().getBaseName(); }
From source file:com.flicklib.folderscanner.MovieNameExtractor.java
public Locale getLanguageSuggestion(FileObject file) { return getLanguageSuggestion(file.getName().getBaseName()); }
From source file:de.innovationgate.wga.common.beans.DesignDefinition.java
/** * Writes syncinfo data to a UTF-8-encoded VFS file object * @param file/*from ww w . j a v a2 s . co m*/ * @throws IOException */ public void write(FileObject file) throws IOException { XStream xStream = createXStreamForFile(file.getName().getBaseName()); XStreamUtils.writeUtf8ToFileObject(this, xStream, file); }
From source file:com.streamsets.pipeline.lib.remote.TestFTPRemoteFile.java
@Test public void testCreateAndCommitOutputStream() throws Exception { String name = "file.txt"; String filePath = "/some/path/"; FileObject fileObject = Mockito.mock(FileObject.class); FileName fileName = Mockito.mock(FileName.class); Mockito.when(fileObject.getName()).thenReturn(fileName); Mockito.when(fileName.getBaseName()).thenReturn(name); FileObject parentFileObject = Mockito.mock(FileObject.class); FileObject tempFileObject = Mockito.mock(FileObject.class); Mockito.when(fileObject.getParent()).thenReturn(parentFileObject); Mockito.when(parentFileObject.resolveFile(Mockito.any())).thenReturn(tempFileObject); FileContent tempFileContent = Mockito.mock(FileContent.class); Mockito.when(tempFileObject.getContent()).thenReturn(tempFileContent); FTPRemoteFile file = new FTPRemoteFile(filePath + name, 0L, fileObject); try {//from w ww. j a va 2 s. c o m file.commitOutputStream(); Assert.fail("Expected IOException because called commitOutputStream before createOutputStream"); } catch (IOException ioe) { Assert.assertEquals("Cannot commit " + filePath + name + " - it must be written first", ioe.getMessage()); } file.createOutputStream(); Mockito.verify(parentFileObject).resolveFile("_tmp_" + name); Mockito.verify(tempFileContent).getOutputStream(); file.commitOutputStream(); Mockito.verify(tempFileObject).moveTo(fileObject); }
From source file:com.flicklib.folderscanner.MovieNameExtractor.java
public String removeCrap(FileObject file) throws FileSystemException { return removeCrap(file.getName().getBaseName(), file.getType().hasChildren()); }
From source file:com.github.junrar.vfs2.provider.rar.RARFileProvider.java
/** * Creates a layered file system. This method is called if the file system * is not cached./*from ww w . j ava2s . c om*/ * * @param scheme * The URI scheme. * @param file * The file to create the file system on top of. * @return The file system. */ @Override protected FileSystem doCreateFileSystem(final String scheme, final FileObject file, final FileSystemOptions fileSystemOptions) throws FileSystemException { final AbstractFileName rootName = new LayeredFileName(scheme, file.getName(), FileName.ROOT_PATH, FileType.FOLDER); return new RARFileSystem(rootName, file, fileSystemOptions); }
From source file:net.sourceforge.fullsync.fs.connection.CommonsVfsConnection.java
@Override public final Map<String, File> getChildren(final File dir) throws IOException { try {/* ww w . j a v a 2s.co m*/ Map<String, File> children = new HashMap<>(); FileObject obj = base.resolveFile(dir.getPath()); if (obj.exists() && (obj.getType() == FileType.FOLDER)) { FileObject[] list = obj.getChildren(); for (FileObject element : list) { children.put(element.getName().getBaseName(), buildNode(dir, element)); } } return children; } catch (org.apache.commons.vfs2.FileSystemException fse) { throw new IOException(fse.getMessage(), fse); } }
From source file:examples.ExampleLogDataParsedListener.java
@Override public void processingFileFinished(BatchProcessingContext batchProcessingContext) { FileObject currentFile = batchProcessingContext.getCurrentFile(); System.out.printf("Finished parsing file %s, found %d event at level warning or higher\n", currentFile.getName().getBaseName(), singleFileCount); }
From source file:com.anrisoftware.sscontrol.filesystem.FileSystem.java
private Set<FileObject> createFileSet() { return new TreeSet<FileObject>(new Comparator<FileObject>() { @Override//w w w. jav a 2s . co m public int compare(FileObject o1, FileObject o2) { return o1.getName().compareTo(o2.getName()); } }); }
From source file:com.googlecode.japi.checker.cli.Main.java
private File writeToTempFile(FileObject fo) throws IOException { File temp = File.createTempFile("lib-", fo.getName().getExtension()); temp.deleteOnExit();//from w w w .ja v a 2 s . c o m InputStream is = fo.getContent().getInputStream(); OutputStream os = new FileOutputStream(temp); int c = 0; try { while ((c = is.read()) != -1) { os.write(c); } } finally { os.close(); is.close(); } return temp; }