Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
JDK 1.1 Source Code Directory
JDK 1.1 source code directory contains Java source code for JDK 1.1 core classes: "C:\fyicenter\jdk-1.1.8\src".
Here is the list of Java classes of the JDK 1.1 source code:
✍: FYIcenter
⏎ java/io/OutputStreamWriter.java
/* * @(#)OutputStreamWriter.java 1.13 01/12/10 * * Copyright 2002 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package java.io; import sun.io.CharToByteConverter; import sun.io.ConversionBufferFullException; /** * Write characters to an output stream, translating characters into bytes * according to a specified character encoding. Each OutputStreamWriter * incorporates its own CharToByteConverter, and is thus a bridge from * character streams to byte streams. * * <p> The encoding used by an OutputStreamWriter may be specified by name, by * providing a CharToByteConverter, or by accepting the default encoding, which * is defined by the system property <tt>file.encoding</tt>. * * <p> Each invocation of a write() method causes the encoding converter to be * invoked on the given character(s). The resulting bytes are accumulated in a * buffer before being written to the underlying output stream. The size of * this buffer may be specified, but by default it is large enough for most * purposes. Note that the characters passed to the write() methods are not * buffered. For top efficiency, consider wrapping an OutputStreamWriter * within a BufferedWriter so as to avoid frequent converter invocations. For * example, * * <pre> * Writer out * = new BufferedWriter(new OutputStreamWriter(System.out)); * </pre> * * @see BufferedWriter * @see OutputStream * * @version 1.10, 97/01/27 * @author Mark Reinhold * @since JDK1.1 */ public class OutputStreamWriter extends Writer { private CharToByteConverter ctb; private OutputStream out; private static final int defaultByteBufferSize = 8192; private byte bb[]; private int nextByte = 0; private int nBytes = 0; /** * Create an OutputStreamWriter that uses the named character encoding. * * @param out An OutputStream * @param enc Name of the encoding to be used * * @exception UnsupportedEncodingException * If the named encoding is not supported */ public OutputStreamWriter(OutputStream out, String enc) throws UnsupportedEncodingException { this(out, CharToByteConverter.getConverter(enc)); } /** * Create an OutputStreamWriter that uses the default character encoding. * * @param out An OutputStream */ public OutputStreamWriter(OutputStream out) { this(out, CharToByteConverter.getDefault()); } /** * Create an OutputStreamWriter that uses the specified character-to-byte * converter. The converter is assumed to have been reset. * * @param out An OutputStream * @param ctb A CharToByteConverter */ private OutputStreamWriter(OutputStream out, CharToByteConverter ctb) { super(out); this.out = out; this.ctb = ctb; bb = new byte[defaultByteBufferSize]; nBytes = defaultByteBufferSize; } /** * Return the name of the encoding being used by this stream. May return * null if the stream has been closed. */ public String getEncoding() { synchronized (lock) { if (ctb != null) return ctb.getCharacterEncoding(); else return null; } } /** Check to make sure that the stream has not been closed */ private void ensureOpen() throws IOException { if (out == null) throw new IOException("Stream closed"); } /** * Write a single character. * * @exception IOException If an I/O error occurs */ public void write(int c) throws IOException { char cbuf[] = new char[1]; cbuf[0] = (char) c; write(cbuf, 0, 1); } /** * Write a portion of an array of characters. * * @param cbuf Buffer of characters * @param off Offset from which to start writing characters * @param len Number of characters to write * * @exception IOException If an I/O error occurs */ public void write(char cbuf[], int off, int len) throws IOException { synchronized (lock) { ensureOpen(); int ci = off, end = off + len; boolean bufferFlushed = false; while (ci < end) { boolean bufferFull = false; try { nextByte += ctb.convert(cbuf, ci, end, bb, nextByte, nBytes); ci = end; } catch (ConversionBufferFullException x) { int nci = ctb.nextCharIndex(); if (nci == ci && bufferFlushed) { /* Buffer has been flushed and still doesn't even hold one character */ throw new CharConversionException("Output buffer too small"); } ci = nci; bufferFull = true; nextByte = ctb.nextByteIndex(); } if ((nextByte >= nBytes) || bufferFull) { out.write(bb, 0, nextByte); nextByte = 0; bufferFlushed = true; } } } } /** * Write a portion of a string. * * @param str A String * @param off Offset from which to start writing characters * @param len Number of characters to write * * @exception IOException If an I/O error occurs */ public void write(String str, int off, int len) throws IOException { char cbuf[] = new char[len]; str.getChars(off, off + len, cbuf, 0); write(cbuf, 0, len); } /** * Flush the output buffer to the underlying byte stream, without flushing * the byte stream itself. This method is non-private only so that it may * be invoked by PrintStream. */ void flushBuffer() throws IOException { synchronized (lock) { ensureOpen(); for (;;) { try { nextByte += ctb.flush(bb, nextByte, nBytes); } catch (ConversionBufferFullException x) { nextByte = ctb.nextByteIndex(); } if (nextByte == 0) break; if (nextByte > 0) { out.write(bb, 0, nextByte); nextByte = 0; } } } } /** * Flush the stream. * * @exception IOException If an I/O error occurs */ public void flush() throws IOException { synchronized (lock) { flushBuffer(); out.flush(); } } /** * Close the stream. * * @exception IOException If an I/O error occurs */ public void close() throws IOException { synchronized (lock) { if (out == null) return; flush(); out.close(); out = null; bb = null; ctb = null; } } }
⏎ java/io/OutputStreamWriter.java
Or download all of them as a single archive file:
File name: jdk-1.1.8-src.zip File size: 1574187 bytes Release date: 2018-11-16 Download
⇒ Backup JDK 1.1 Installation Directory
2018-11-17, 149183👍, 0💬
Popular Posts:
maven-core-3.5.4.jar is the JAR file for Apache Maven 3.5.4 Core module. Apache Maven is a software ...
ZooKeeper is a centralized service for maintaining configuration information, naming, providing dist...
JRE 8 rt.jar is the JAR file for JRE 8 RT (Runtime) libraries. JRE (Java Runtime) 8 is the runtime e...
What Is commons-codec-1.4.jar? commons-codec-1.4.jar is the JAR file for Apache Commons Codec 1.4, w...
What Is commons-logging-1.2.jar? commons-logging-1.2.jar is the JAR file for Apache Commons Logging ...