Write the header for the given stream to the stream.

@param source Bundle stream
@param buffer Buffer to use for writing
@param output Output channel
@return Array of serializers
@throws IOException on IO errors
433580
private ByteBufferSerializer<?>[] writeHeader(BundleStreamSource source, ByteBuffer buffer, WritableByteChannel output) throws IOException {
    final BundleMeta meta = source.getMeta();
    final int nummeta = meta.size();
    @SuppressWarnings("rawtypes")
    final ByteBufferSerializer[] serializers = new ByteBufferSerializer[1 + nummeta];
    // Write our magic ID first.
    assert (buffer.position() == 0) : "Buffer is supposed to be at 0.";
    buffer.putInt(MAGIC);
    // Write the number of metas next.
    // For compatibility with earlier versions, treat DBIDs as extra type
    if(source.hasDBIDs()) {
      buffer.putInt(1 + nummeta);
      ByteBufferSerializer<DBID> ser = DBIDFactory.FACTORY.getDBIDSerializer();
      TypeInformationSerializer.STATIC.toByteBuffer(buffer, new SimpleTypeInformation<>(DBID.class, ser));
      serializers[0] = ser;
    }
    else {
      buffer.putInt(nummeta);
    }
    for(int i = 0; i < nummeta; i++) {
      SimpleTypeInformation<?> type = meta.get(i);
      ByteBufferSerializer<?> ser = type.getSerializer();
      if(ser == null) {
        throw new AbortException("Cannot serialize - no serializer found for type: " + type.toString());
      }
      TypeInformationSerializer.STATIC.toByteBuffer(buffer, type);
      serializers[i + 1] = ser;
    }
    return serializers;
  }
277894
public static int writeListTo(OutputStream out, Vector messages, Schema schema, 
            LinkedBuffer buffer) throws IOException
    {
        if(buffer.start != buffer.offset)
            throw new IllegalArgumentException("Buffer previously used and had not been reset.");
        
        final ProtobufOutput output = new ProtobufOutput(buffer);
        int totalSize = 0;
        for(int i = 0; i < messages.size(); i++)
        {
        	Object m = messages.elementAt(i);
            schema.writeTo(output, m);
            final int size = output.getSize();
            ProtobufOutput.writeRawVarInt32Bytes(out, size);
            LinkedBuffer.writeTo(out, buffer);
            //final int msgSize = LinkedBuffer.writeTo(out, buffer);
            //assert size == msgSize;
            
            totalSize += size;
            output.clear();
        }
        return totalSize;
    }
996958
public void writeContent(final OutputStream result) throws IOException
    {
        if(this.mode == MODE_SINGLE) {
        	headerAll.writeContent(result);
        } else if(this.mode == MODE_MULTIPLE) {
            if(headerFirst != null) {
            	headerFirst.writeContent(result);
            }
            if(headerLeft != null) {
                headerLeft.writeContent(result);
            }
            if(headerRight != null) {
                headerRight.writeContent(result);
            }
            if(headerAll != null) {
                headerAll.writeContent(result);
            }
        }
    }
525537
private void writeHeader(OutputStream stream, Header header) throws IOException {
        DataOutputStream dos = new DataOutputStream(stream);
        dos.writeUTF(HEADER);

        // Write the current version
        dos.writeInt(1);

        // Write the normalizer opType
        dos.writeUTF(header.normalizerType.toString());

        // If the header contains a custom class opName, write that too
        if (header.customStrategyClass != null) {
            dos.writeUTF(header.customStrategyClass.getName());
        }
    }
744166
private static void serializeDocToStream(final OutputStream output, final Document doc) throws IOException {
        final OutputFormat format = OutputFormat.createPrettyPrint();
        final XMLWriter writer = new XMLWriter(output, format);
        writer.write(doc);
        writer.flush();
    }
410337
public static void writeBuffer(DataOutput out, ByteBuffer buffer) throws IOException {
        if (buffer.hasArray()) {
            out.write(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining());
            buffer.position(buffer.limit());
        } else {
            final byte[] array = new byte[buffer.remaining()];
            buffer.get(array);
            assert buffer.remaining() == 0 && buffer.position() == buffer.limit();
            out.write(array);
        }
    }
448599
public void write(final OutputStream out, final Stream<? extends Triple> triples, final IRI subject) {
        final Writer writer = new OutputStreamWriter(out, UTF_8);
        try {
            template
                .execute(writer, new HtmlData(namespaceService, subject, triples.collect(toList()), properties))
                .flush();
        } catch (final IOException ex) {
            throw new UncheckedIOException(ex);
        }
    }
423095
public static int writeListTo(final OutputStream out, final Vector messages, 
            final Schema schema, final LinkedBuffer buffer) throws IOException
    {
        if(buffer.start != buffer.offset)
            throw new IllegalArgumentException("Buffer previously used and had not been reset.");
        
        final int size = messages.size();
        if(size == 0)
            return 0;
        
        final ProtostuffOutput output = new ProtostuffOutput(buffer, out);
        output.sink.writeVarInt32(size, output, buffer);

        for(int i = 0; i < messages.size(); i++)
        {
        	Object m = messages.elementAt(i);
            schema.writeTo(output, m);
            output.sink.writeByte((byte)WireFormat.WIRETYPE_TAIL_DELIMITER, output, 
                    buffer);
        }
        
        LinkedBuffer.writeTo(out, buffer);
        
        return output.size;
    }
10489
@Override
	public void write(final OutputStream output) throws IOException
	{
		initialize();
		if (content == null)
		{
			content = new byte[0];
		}
		output.write(content, 0, content.length);
		output.flush();
	}
890798
public static void print(Object o, OutputStream outs, boolean typeheader) throws IOException {
		OutputStreamWriter w=new OutputStreamWriter(outs,"UTF-8");
		print(o,w,typeheader);
		w.flush();
	}
565593
@Override
  public void write(Buffer buffer, boolean isEnd)
    throws IOException
  {
    if (_s == null) {
      buffer.free();
      return;
    }
    
    try {
      _needsFlush = true;
      
      if (buffer.isDirect()) {
        _totalWriteBytes += buffer.length(); 
        _s.write(buffer.direct());
        return;
      }
      
      _totalWriteBytes += buffer.length();
      
      while (buffer.length() > 0) {
        _writeBuffer.clear();
        
        buffer.read(_writeBuffer);
        _writeBuffer.flip();
        
        _s.write(_writeBuffer);
      }
    } catch (IOException e) {
      IOException exn = ClientDisconnectException.create(this + ":" + e, e);
      
      try {
        close();
      } catch (IOException e1) {
      }

      throw exn;
    } finally {
      buffer.free();
    }
  }
1164239
public static void string2Writer(String source, Writer out) throws IOException {

		char[] buffer = source.toCharArray();
		for (int i = 0; i < buffer.length; i++) {
			out.append(buffer[i]);
		}
		out.flush();
	}
67238
private void writeObject(java.io.ObjectOutputStream out)
                    throws IOException
    {
        out.defaultWriteObject();
        // write out the header information
        out.write(eyecatcher);
        out.writeShort(platform);
        out.writeShort(versionID);

        // write out the data
        out.writeObject(server);
        out.writeObject(allWrappers);
        out.writeInt(chunkSize);
    }
828316
public void writeTo(OutputStream out)
        throws IOException
    {
        out.write(_buf,_start,_pos-_start);
    }
1010652
public void write(ByteBuffer buffer) throws IOException {
		synchronized (buffers) {
			if (writing == null) {
				writing = io.writeAsync(buffer);
				writing.listenInline(listener);
				return;
			}
			if (writing.hasError()) throw writing.getError();
			buffers.add(buffer);
		}
	}
1027283
public static void copy(InputStream input, OutputStream output) throws IOException {
		byte[] buf = new byte[BUFFER_SIZE];
		int num = 0;

		while ((num = input.read(buf, 0, buf.length)) != -1) {
			output.write(buf, 0, num);
		}
	}
640751
public static void writeToOutputStream(String s, OutputStream output) throws IOException {
		writeToOutputStream(s, output, null);
	}