Returns the PDF representation of this <CODE>PdfOutline</CODE>.

@param writer the encryption information
@param os
@throws IOException
559159
public void toPdf(PdfWriter writer, OutputStream os) throws IOException {
        if (color != null && !color.equals(Color.black)) {
            put(PdfName.C, new PdfArray(new float[]{color.getRed()/255f,color.getGreen()/255f,color.getBlue()/255f}));
        }
        int flag = 0;
        if ((style & Font.BOLD) != 0)
            flag |= 2;
        if ((style & Font.ITALIC) != 0)
            flag |= 1;
        if (flag != 0)
            put(PdfName.F, new PdfNumber(flag));
        if (parent != null) {
            put(PdfName.PARENT, parent.indirectReference());
        }
        if (destination != null && destination.hasPage()) {
            put(PdfName.DEST, destination);
        }
        if (action != null)
            put(PdfName.A, action);
        if (count != 0) {
            put(PdfName.COUNT, new PdfNumber(count));
        }
        super.toPdf(writer, os);
    }
232684
public static void write(Object value, Writer out) throws IOException {
		if(out instanceof MediaWriter) {
			// Unwrap media writer and use encoder directly
			MediaWriter mediaWriter = (MediaWriter)out;
			write(
				value,
				mediaWriter.getEncoder(),
				mediaWriter.getOut()
			);
		} else {
			if(value instanceof String) {
				// If A is a string, then the result is A.
				out.write((String)value);
			} else if(value == null) {
				// Otherwise, if A is null, then the result is "".
				// Write nothing
			} else if(value instanceof Writable) {
				Writable writable = (Writable)value;
				if(writable.isFastToString()) {
					out.write(writable.toString());
				} else {
					// Avoid intermediate String from Writable
					writable.writeTo(unwrap(out));
				}
			} else if(value instanceof Node) {
				// Otherwise, if is a DOM node, serialize the output
				try {
					// Can use thread-local or pooled transformers if performance is ever an issue
					TransformerFactory transFactory = TransformerFactory.newInstance();
					Transformer transformer = transFactory.newTransformer();
					transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
					transformer.transform(
						new DOMSource((Node)value),
						new StreamResult(unwrap(out))
					);
				} catch(TransformerException e) {
					throw new IOException(e);
				}
			} else {
				// Otherwise, if A.toString() throws an exception, then raise an error
				// Otherwise, the result is A.toString();
				out.write(value.toString());
			}
		}
	}
6766
@Override
	public void onCloseDocument(final PdfWriter writer, final Document document) {
		template.beginText();
		template.setFontAndSize(bf, 8);
		template.showText(String.valueOf(writer.getPageNumber() - 1));
		template.endText();
	}
1335760
public TextWriterWriterInterface<?> getWriterFor(Object o) {
    if(o == null) {
      return null;
    }
    TextWriterWriterInterface<?> writer = writers.getHandler(o);
    if(writer != null) {
      return writer;
    }
    try {
      final Class<?> decl = o.getClass().getMethod("toString").getDeclaringClass();
      if(decl == Object.class) {
        return null; // TODO: cache this, too
      }
      writers.insertHandler(decl, fallbackwriter);
      return fallbackwriter;
    }
    catch(NoSuchMethodException | SecurityException e) {
      return null;
    }
  }
1322750
@edu.umd.cs.findbugs.annotations.SuppressWarnings({"DM_DEFAULT_ENCODING", "OS_OPEN_STREAM"})
    private static void getUlimit(PrintWriter writer) throws IOException {
        // TODO should first check whether /bin/bash even exists
        InputStream is = new ProcessBuilder("bash", "-c", "ulimit -a").start().getInputStream();
        try {
            // this is reading from the process so platform encoding is correct
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                writer.println(line);
            }
        } finally {
            is.close();
        }
    }
1019573
public void writeRequestLine(Writer writer) throws IOException
    {
        writer.write(_method);
        writer.write(' ');
        writer.write(_uri != null ? _uri.toString() : "null");
        writer.write(' ');
        writer.write(_version);
    }
322639
public PrintWriter getWriter()
        throws java.io.IOException 
    {
        if (_outputState==DISABLED)
            return __nullServletWriter;
                                   
        if (_outputState!=NO_OUT && _outputState!=WRITER_OUT)
            throw new IllegalStateException();

        // If we are switching modes, flush output to try avoid overlaps.
        if (_out!=null)
            _out.flush();
        
        /* if there is no writer yet */
        if (_writer==null)
        {
            /* get encoding from Content-Type header */
            String encoding = _httpResponse.getCharacterEncoding();
            
            if (encoding==null)
            {
                if (_servletHttpRequest!=null)
                {
                    /* implementation of educated defaults */
                    String mimeType = _httpResponse.getMimeType();                
                    encoding = _servletHttpRequest.getServletHandler()
                    	.getHttpContext().getEncodingByMimeType(mimeType);
                }
                if (encoding==null)
                    encoding = StringUtil.__ISO_8859_1; 
                _httpResponse.setCharacterEncoding(encoding,true);
            }
            
            /* construct Writer using correct encoding */
            _writer = new ServletWriter(_httpResponse.getOutputStream(), encoding);
        }                    
        _outputState=WRITER_OUT;
        return _writer;
    }
87265
@SuppressWarnings("unchecked")
    public static <E> void serialize(E object, OutputStream os) throws IOException {
        mapperFor((Class<E>)object.getClass()).serialize(object, os);
    }
850651
public byte[] sendOutbind(OutputStream os, int sequenceNumber, String systemId, String password)
        throws PDUStringException, IOException
    {
        byte[] b = this.pduComposer.outbind( sequenceNumber,systemId, password);
        writeAndFlush(os, b);
        return b;
    }
12174
@Override
    public void write(Writer out, boolean escapeXML) throws IOException {
        final String url = this.toURL();
        if (escapeXML) {
            StringEscapeUtils.escapeXml(out, url);
        } else {
            out.write(url);
        }
    }
282504
public void write(ByteCodeWriter out)
    throws IOException
  {
    out.writeUTF8Const(getName());

    TempOutputStream ts = new TempOutputStream();
    //ts.openWrite();
    //WriteStream ws = new WriteStream(ts);
    ByteCodeWriter o2 = new ByteCodeWriter(ts, out.getJavaClass());

    o2.writeShort(_exceptions.size());
    for (int i = 0; i < _exceptions.size(); i++) {
      String exn = _exceptions.get(i);

      o2.writeClass(exn);
    }
    
    ts.close();
    
    out.writeInt(ts.getLength());
    
    TempBuffer ptr = ts.getHead();

    for (; ptr != null; ptr = ptr.next())
      out.write(ptr.buffer(), 0, ptr.length());

    ts.destroy();
  }
964869
public void encode(InputStream is, OutputStream os) throws IOException {
    	// StringBuilder sb = new StringBuilder((int)(estimate*1.255)); // try to get the right size of StringBuilder from start.. slightly more than 1.25 times 
    	int prev=0;
    	int read, idx=0, line=0;
    	boolean go;
    	do {
    		read = is.read();
    		if(go = read>=0) {
    			if(line>=splitLinesAt) {
	    			os.write('\n');
	    			line = 0;
	    		}
	    		switch(++idx) { // 1 based reading, slightly faster ++
	    			case 1: // ptr is the first 6 bits of read
	    				os.write(codeset[read>>2]);
	    				prev = read;
	    				break;
	    			case 2: // ptr is the last 2 bits of prev followed by the first 4 bits of read
	    				os.write(codeset[((prev & 0x03)<<4) | (read>>4)]);
    					prev = read;
	    				break;
	    			default: //(3+) 
	    					// Char 1 is last 4 bits of prev plus the first 2 bits of read
	    				    // Char 2 is the last 6 bits of read
	    				os.write(codeset[(((prev & 0xF)<<2) | (read>>6))]);
	    				if(line==splitLinesAt) { // deal with line splitting for two characters
	    					os.write('\n');
	    					line=0;
	    				}
	    				os.write(codeset[(read & 0x3F)]);
	    				++line;
	    				idx = 0;
	    				prev = 0;
	    		}
	    		++line;
    		} else { // deal with any remaining bits from Prev, then pad
    			switch(idx) {
    				case 1: // just the last 2 bits of prev
	    				os.write(codeset[(prev & 0x03)<<4]);
    					if(endEquals)os.write(DOUBLE_EQ);
    					break;
    				case 2: // just the last 4 bits of prev
	    				os.write(codeset[(prev & 0xF)<<2]);
	    				if(endEquals)os.write('=');
	    				break;
    			}
    			idx = 0;
    		}
    		
    	} while(go);
    }
325768
def pdf_from_writer(writer: Union[PdfFileWriter, PdfFileMerger]) -> bytes:
    
    memfile = io.BytesIO()
    writer.write(memfile)
    memfile.seek(0)
    return memfile.read()
672610
@Override
    public PrintWriter getWriter() throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "getWriter: " + this);
        }
        if (this.streamActive) {
            throw new IllegalStateException("Output stream already obtained");
        }
        if (null == this.outWriter) {
            this.outWriter = new PrintWriter(
                            new OutputStreamWriter(
                                            this.outStream, getCharacterEncoding()), false);
        }
        return this.outWriter;
    }
393683
public static void write(Writer out, Object object) throws IOException {
        if (object instanceof String) {
            out.write((String) object);
        } else if (object instanceof Object[]) {
            out.write(toArrayString((Object[]) object));
        } else if (object instanceof Map) {
            out.write(toMapString((Map) object));
        } else if (object instanceof Collection) {
            out.write(toListString((Collection) object));
        } else if (object instanceof Writable) {
            Writable writable = (Writable) object;
            writable.writeTo(out);
        } else if (object instanceof InputStream || object instanceof Reader) {
            // Copy stream to stream
            Reader reader;
            if (object instanceof InputStream) {
                reader = new InputStreamReader((InputStream) object);
            } else {
                reader = (Reader) object;
            }

            try (Reader r = reader) {
                char[] chars = new char[8192];
                for (int i; (i = r.read(chars)) != -1; ) {
                    out.write(chars, 0, i);
                }
            }
        } else {
            out.write(toString(object));
        }
    }
1065807
public static void encode (Writer writer, String string, boolean encodeNewline) throws IOException
    {
        encode(writer, string, encodeNewline, true);
    }
1209171
@Override
	public void writeHeader(OutputStream os) throws IOException {	
		os.write(ascii("Content-Disposition: form-data; name=\"" + enc(controlName)
				 + "\"" +
				((fileName != null) ? "; filename=\"" + enc(fileName) + "\"" : "") + "\r\n")); 
		wrappedContent.writeHeader(os);
	}