/** * Create and return an OutputStream for writing the contents of the file represented by this entry * * @param append - true if the OutputStream should append to any existing contents false if * any existing contents should be overwritten * @return an OutputStream * @throws FileSystemException - if an error occurs creating or initializing the OutputStream */ public OutputStream createOutputStream(boolean append) { // If appending and we already have an OutputStream, then continue to use it if (append && out != null) { return out; } out = new ByteArrayOutputStream(); byte[] initialContents = (append) ? bytes : EMPTY; try { out.write(initialContents); } catch (IOException e) { throw new FileSystemException(getPath(), null, e); } return out; }
/** * @see java.lang.Object#toString() */ public String toString() { return "File['" + getPath() + "' size=" + getSize() + " lastModified=" + getLastModified() + " owner=" + getOwner() + " group=" + getGroup() + " permissions=" + getPermissions() + "]"; }
/** * Stop the fakeFtpServer. Remove all temp files from the baseDir * <p/> * The fakeFtpServer demon will normally be stopped by JUnit using the after() method. This method allows the sshd to * be stopped manually to support advanced testing scenarios. */ public void stop() { for(Object file:fakeFtpServer.getFileSystem().listFiles(baseDir)){ fakeFtpServer.getFileSystem().delete(((FileEntry)file).getPath()); } fakeFtpServer.getFileSystem().delete(baseDir); fakeFtpServer.stop(); }