/** * Returns the last modified time of this file. */ protected long doGetLastModifiedTime() throws Exception { return container.getContent().getLastModifiedTime(); }
/** * Creates an output stream to write the file content to. */ protected OutputStream doGetOutputStream(boolean bAppend) throws Exception { return file.getContent().getOutputStream(bAppend); }
protected void copy(File localFile, FileObject remoteFile) throws TinkException, IOException { OutputStream out = remoteFile.getContent().getOutputStream(); InputStream in = new FileInputStream(localFile); byte[] buff = new byte[1024]; for (int n = in.read(buff); n > 0; n = in.read(buff)) { out.write(buff, 0, n); } out.close(); in.close(); }
/** * Returns the size of the file content (in bytes). Is only called if * {@link #doGetType} returns {@link FileType#FILE}. */ protected long doGetContentSize() throws Exception { return file.getContent().getSize(); }
/** * Creates an input stream to read the file content from. */ protected InputStream doGetInputStream() throws Exception { return file.getContent().getInputStream(); }
/** * Returns the attributes of this file. */ protected Map doGetAttributes() throws Exception { return file.getContent().getAttributes(); }
/** * Returns the last-modified time of this file. */ protected long doGetLastModifiedTime() throws Exception { return file.getContent().getLastModifiedTime(); }
/** * Sets an attribute of this file. */ protected void doSetAttribute(final String atttrName, final Object value) throws Exception { file.getContent().setAttribute(atttrName, value); }
/** * Returns the certificates of this file. */ protected Certificate[] doGetCertificates() throws Exception { return file.getContent().getCertificates(); }
/** * Sets the last-modified time of this file. */ protected void doSetLastModifiedTime(final long modtime) throws Exception { file.getContent().setLastModifiedTime(modtime); }
protected URLConnection openConnection(final URL url) throws IOException { final FileObject entry = context.resolveFile(url.toExternalForm(), fileSystemOptions); return new DefaultURLConnection(url, entry.getContent()); }
protected OutputStream doGetOutputStream(boolean bAppend) throws Exception { OutputStream os = getContainer().getContent().getOutputStream(false); return new GZIPOutputStream(os); } }
protected InputStream doGetInputStream() throws Exception { InputStream is = getContainer().getContent().getInputStream(); return new GZIPInputStream(is); }
protected String readURL(URL url) throws FileNotFoundException, IOException { if (url.toExternalForm().startsWith("vfs")) { FileObject from = VFS.getManager().resolveFile(url.toExternalForm()); return IOUtils.toString(from.getContent().getInputStream()); } else { return FileUtils.readFileToString(FileUtils.toFile(url)); } } }
protected String readURL(URL url) throws FileNotFoundException, IOException { if (url.toExternalForm().startsWith("vfs")) { FileObject from = VFS.getManager().resolveFile(url.toExternalForm()); return IOUtils.toString(from.getContent().getInputStream()); } else { return FileUtils.readFileToString(FileUtils.toFile(url)); } } }
/** * Returns an attribute of the package containing the resource. */ public String getPackageAttribute(final Attributes.Name attrName) throws FileSystemException { return (String) packageFolder.getContent().getAttribute(attrName.toString()); }
public Object call() throws Exception { FileObject toFile = root.resolveFile( to.path.string ); toFile.getParent().createFolder(); toFile.copyFrom( from, Selectors.SELECT_SELF ); toFile.getContent().setLastModifiedTime( to.lastModified.toDateTime().toDate().getTime() ); return Unit.unit(); } };
protected InputStream doGetInputStream() throws Exception { // check file InputStream is = getContainer().getContent().getInputStream(); return wrapInputStream(getName().getURI(), is); }
public static UnixFsObject.RegularFile fromFileObject( RelativePath toFile, FileObject fromFile, FileAttributes attributes ) throws FileSystemException { FileContent content = fromFile.getContent(); LocalDateTime time = new LocalDateTime( content.getLastModifiedTime() ); return regularFile( toFile, time, content.getSize(), fromNull( attributes ) ); }
public static UnixFsObject.Directory dirFromFileObject( RelativePath toFile, FileObject fromFile, FileAttributes attributes ) throws FileSystemException { if ( !fromFile.getType().equals( FileType.FOLDER ) ) { throw new FileSystemException( "Not a directory: " + fromFile.getName().getPath() + ", was: " + fromFile.getType() ); } FileContent content = fromFile.getContent(); return UnixFsObject.directory( toFile, new LocalDateTime( content.getLastModifiedTime() ), attributes ); } }