List of usage examples for org.apache.commons.vfs FileObject getContent
public FileContent getContent() throws FileSystemException;
From source file:com.pongasoft.kiwidoc.builder.bytecode.ByteCodeParser.java
public void parseClasses(LibraryModelBuilder library, FileObject classesResource) throws IOException { FileObject[] classes = classesResource.findFiles(ClassFileSelector.INSTANCE); // TODO MED YP: handle inner classes (classModelBuilder.addInnerClass...) if (classes != null) { for (FileObject classResource : classes) { ClassModelBuilder classModelBuilder; InputStream is = classResource.getContent().getInputStream(); try { ClassReader reader = new ClassReader(new BufferedInputStream(is)); KiwidocClassVisitor classParser = new KiwidocClassVisitor(); reader.accept(classParser, 0); classModelBuilder = classParser.getClassModel(); } finally { is.close();//from w ww .jav a 2s .c o m } library.addClass(classModelBuilder); } } }
From source file:edu.scripps.fl.pubchem.PubChemFactory.java
public InputStream getPubChemCsv(long aid) throws IOException { String archive = getAIDArchive(aid); String sUrl = String.format(pubchemBioAssayUrlFormat, ftpUser, ftpPass, "Data", archive); String szip = String.format("zip:%s!/%s/%s.csv.gz", sUrl, archive, aid); log.debug(sUrl);// www . j a v a2 s. c o m FileObject fo = VFS.getManager().resolveFile(szip); log.debug("Resolved file: " + szip); InputStream is = fo.getContent().getInputStream(); return new GZIPInputStream(is); }
From source file:edu.scripps.fl.pubchem.PubChemFactory.java
public InputStream getPubChemXmlDesc(long aid) throws IOException { String archive = getAIDArchive(aid); String sUrl = String.format(pubchemBioAssayUrlFormat, ftpUser, ftpPass, "Description", archive); String szip = String.format("zip:%s!/%s/%s.descr.xml.gz", sUrl, archive, aid); log.debug(sUrl);/*from w w w . j av a 2 s . co m*/ FileObject fo = VFS.getManager().resolveFile(szip); log.debug("Resolved file: " + szip); try { InputStream is = fo.getContent().getInputStream(); return new GZIPInputStream(is); } catch (Exception e) { log.info("AID: " + aid + " is not in the ftp site.", e.getMessage()); return null; } }
From source file:com.qmetric.document.watermark.PdfWatermarkService.java
void watermark(final String documentSourcePath, final String documentOutputPath, final PdfWatermarkStrategy pdfWatermarkStrategy) throws Exception { // source reader final FileObject sourcePdf = fileUtils.resolveFile(documentSourcePath); final PdfReader reader; try {/*from www . j av a 2s .c o m*/ reader = pdfReaderFactory.newPdfReader(sourcePdf.getContent()); } catch (final IOException e) { throw new RuntimeException(String.format( "Failed to create new pdf reader because pdf password was incorrect. documentSourcePath[%s], " + "documentOutputPath[%s]", documentSourcePath, documentOutputPath), e); } // create a stamper that will copy the document to a new file FileObject outputFile = null; PdfStamper outputPdf = null; try { outputFile = fileUtils.resolveFile(documentOutputPath); outputPdf = pdfStamperFactory.newPdfStamper(reader, outputFile.getContent()); pdfWatermarkStrategy.apply(reader, outputPdf); } finally { cleanUp(sourcePdf, outputFile, outputPdf); } }
From source file:com.naryx.tagfusion.cfm.file.cfFileEncoding.java
public cfFileEncoding(FileObject _f) throws cfmBadFileException, IOException { init(_f.getContent().getInputStream()); }
From source file:com.naryx.tagfusion.cfm.file.cfFileEncoding.java
public cfFileEncoding(FileObject _f, boolean _s) throws cfmBadFileException, IOException { init(_f.getContent().getInputStream(), _s); }
From source file:com.naryx.tagfusion.cfm.file.cfFileEncoding.java
public InputStreamReader getReader(FileObject _file) throws IOException, cfmBadFileException { return getReader(_file.getContent().getInputStream()); // input stream is already buffered }
From source file:com.nary.util.LogFileObject.java
private LogFileObject(FileObject logPath) throws Exception { filename = logPath;/* w w w. j av a 2s . co m*/ if (!logPath.exists()) logPath.createFile(); outFileRandomAccess = logPath.getContent().getRandomAccessContent(RandomAccessMode.READWRITE); logFileSize = outFileRandomAccess.length(); outFileRandomAccess.seek(logFileSize); }
From source file:com.thinkberg.webdav.HeadHandler.java
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { FileObject object = VFSBackend.resolveFile(request.getPathInfo()); if (object.exists()) { if (FileType.FOLDER.equals(object.getType())) { response.sendError(HttpServletResponse.SC_FORBIDDEN); } else {// ww w .jav a 2 s. c o m setHeader(response, object.getContent()); } } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); } }
From source file:com.thinkberg.moxo.dav.HeadHandler.java
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { FileObject object = getResourceManager().getFileObject(request.getPathInfo()); if (object.exists()) { if (FileType.FOLDER.equals(object.getType())) { response.sendError(HttpServletResponse.SC_FORBIDDEN); } else {//from w ww . ja v a 2s . c o m setHeader(response, object.getContent()); } } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); } }