List of usage examples for org.apache.commons.vfs FileContent getOutputStream
OutputStream getOutputStream(boolean bAppend) throws FileSystemException;
From source file:com.panet.imeta.core.vfs.KettleVFS.java
public static OutputStream getOutputStream(FileObject fileObject, boolean append) throws IOException { FileObject parent = fileObject.getParent(); if (parent != null) { if (!parent.exists()) { throw new IOException( Messages.getString("KettleVFS.Exception.ParentDirectoryDoesNotExist", getFilename(parent))); }//from w w w . j a va 2s . com } try { fileObject.createFile(); FileContent content = fileObject.getContent(); return content.getOutputStream(append); } catch (FileSystemException e) { // Perhaps if it's a local file, we can retry using the standard // File object. This is because on Windows there is a bug in VFS. // if (fileObject instanceof LocalFile) { try { String filename = getFilename(fileObject); return new FileOutputStream(new File(filename), append); } catch (Exception e2) { throw e; // throw the original exception: hide the retry. } } else { throw e; } } }
From source file:org.pentaho.di.core.vfs.KettleVFS.java
public static OutputStream getOutputStream(FileObject fileObject, boolean append) throws IOException { FileObject parent = fileObject.getParent(); if (parent != null) { if (!parent.exists()) { throw new IOException(BaseMessages.getString(PKG, "KettleVFS.Exception.ParentDirectoryDoesNotExist", getFilename(parent))); }/*from w w w . j a v a 2s.co m*/ } try { fileObject.createFile(); FileContent content = fileObject.getContent(); return content.getOutputStream(append); } catch (FileSystemException e) { // Perhaps if it's a local file, we can retry using the standard // File object. This is because on Windows there is a bug in VFS. // if (fileObject instanceof LocalFile) { try { String filename = getFilename(fileObject); return new FileOutputStream(new File(filename), append); } catch (Exception e2) { throw e; // throw the original exception: hide the retry. } } else { throw e; } } }