/** * Obtain an {@link OutputStream} to the source * * @return an {@link OutputStream} * @see org.apache.excalibur.source.ModifiableSource#getOutputStream() */ public OutputStream getOutputStream() throws IOException { return m_fileContent.getOutputStream(); }
public OutputStream getOutputStream() throws IOException { return content.getOutputStream(); }
public OutputStream getOutputStream() throws IOException { return content.getOutputStream(); }
/** * 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(); }
protected OutputStream doGetOutputStream(boolean bAppend) throws Exception { OutputStream os = getContainer().getContent().getOutputStream(false); return new GZIPOutputStream(os); } }
protected OutputStream doGetOutputStream(boolean bAppend) throws Exception { OutputStream os = getContainer().getContent().getOutputStream(false); os.write('B'); os.write('Z'); return new CBZip2OutputStream(os); } }
/** * Copies the content from a source file to a destination file. */ public static void copyContent(final FileObject srcFile, final FileObject destFile) throws IOException { // Create the output stream via getContent(), to pick up the // validation it does final OutputStream outstr = destFile.getContent().getOutputStream(); try { writeContent(srcFile, outstr); } finally { outstr.close(); } }
/** * Get the VFS path output stream to write into. * * @param vfsPath the VFS path. * @return the output stream. * @throws FileManipulatorException in case of writing failure. */ public OutputStream write( String vfsPath ) throws FileManipulatorException { FileObject file = null; try { file = this.resolveFile( vfsPath ); if ( file.exists() && !file.getType().equals( FileType.FILE ) ) { LOGGER.error( "{} is not a file", vfsPath ); throw new IllegalArgumentException( vfsPath + " is not a file" ); } return file.getContent().getOutputStream(); } catch ( Exception e ) { LOGGER.error( "Can't write {}", vfsPath, e ); throw new FileManipulatorException( "Can't write " + vfsPath, e ); } }
@SuppressWarnings({"unchecked"}) public void set(final Object value) { assert value != null; log.trace("Setting: {} -> {}", file.getName(), value); BufferedOutputStream output = null; try { Marshaller marshaller = xstore.getMarshaller(value.getClass()); output = new BufferedOutputStream(file.getContent().getOutputStream()); marshaller.marshal(value, output); } catch (FileSystemException e) { throw new XStoreException(e); } finally { Closer.close(output); } }
/** * Transfer an Ivy resource to a VFS repository * * @param source * a <code>File</code> indentifying the local file to transfer to the repository * @param vfsURI * a <code>String</code> identifying the destination VFS Resource. * @param overwrite * whether to overwrite an existing resource. * @throws <code>IOException</code> on failure. * @see "Supported File Systems in the jakarta-commons-vfs documentation" */ public void put(File source, String vfsURI, boolean overwrite) throws IOException { VfsResource dest = new VfsResource(vfsURI, getVFSManager()); fireTransferInitiated(dest, TransferEvent.REQUEST_PUT); if (dest.physicallyExists() && !overwrite) { throw new IOException("Cannot copy. Destination file: " + dest.getName() + " exists and overwrite not set."); } if (dest.getContent() == null) { throw new IllegalArgumentException("invalid vfs uri " + vfsURI + " to put data to: resource has no content"); } FileUtil.copy(new FileInputStream(source), dest.getContent().getOutputStream(), progress); }
/** * Verifies that the method <code>expandToPath()</code> works. * * @throws Exception If an unexpected error occurs */ public void testExpandToPath() throws Exception { FileObject testJar = this.fsManager.resolveFile("ram:///test.jar"); ZipOutputStream zos = new ZipOutputStream(testJar.getContent().getOutputStream()); ZipEntry zipEntry = new ZipEntry("rootResource.txt"); zos.putNextEntry(zipEntry); zos.write("Some content".getBytes("UTF-8")); zos.closeEntry(); zos.close(); DefaultJarArchive jarArchive = new DefaultJarArchive("ram:///test.jar"); jarArchive.setFileHandler(new VFSFileHandler(this.fsManager)); jarArchive.expandToPath("ram:///test"); // Verify that the rootResource.txt file has been correctly expanded assertTrue(this.fsManager.resolveFile("ram:///test/rootResource.txt").exists()); } }
/** * Gets the {@link OutputStream} for a given file. {@inheritDoc} * @param file File name. * @return {@link OutputStream} for <code>file</code>. */ @Override public OutputStream getOutputStream(String file) { OutputStream result; try { result = getFileSystemManager().resolveFile(file).getContent().getOutputStream(); } catch (FileSystemException e) { throw new CargoException("Failed to open output stream for file [" + file + "]", e); } return result; }