public OutputStream getOutputStream()

in taverna-server-webapp/src/main/java/org/apache/taverna/server/master/soap/FileContents.java [153:183]


	public OutputStream getOutputStream() throws IOException {
		final File f = this.f;
		return new OutputStream() {
			private boolean append = false;

			@Override
			public void write(int b) throws IOException {
				write(new byte[] { (byte) b });
			}

			@Override
			public void write(byte[] b) throws IOException {
				try {
					if (append)
						f.appendContents(b);
					else
						f.setContents(b);
					append = true;
				} catch (FilesystemAccessException e) {
					throw new IOException(e);
				}
			}

			@Override
			public void write(byte[] b, int off, int len) throws IOException {
				byte[] ary = new byte[len];
				arraycopy(b, off, ary, 0, len);
				write(ary);
			}
		};
	}