home *** CD-ROM | disk | FTP | other *** search
- package java.io;
-
- import sun.io.CharToByteConverter;
- import sun.io.ConversionBufferFullException;
-
- public class OutputStreamWriter extends Writer {
- private CharToByteConverter ctb;
- private OutputStream out;
- private static final int defaultByteBufferSize = 8192;
- // $FF: renamed from: bb byte[]
- private byte[] field_0;
- private int nextByte;
- private int nBytes;
-
- public OutputStreamWriter(OutputStream var1, String var2) throws UnsupportedEncodingException {
- this(var1, CharToByteConverter.getConverter(var2));
- }
-
- public OutputStreamWriter(OutputStream var1) {
- this(var1, CharToByteConverter.getDefault());
- }
-
- private OutputStreamWriter(OutputStream var1, CharToByteConverter var2) {
- super(var1);
- this.out = var1;
- this.ctb = var2;
- this.field_0 = new byte[8192];
- this.nBytes = 8192;
- }
-
- public String getEncoding() {
- Object var2 = super.lock;
- synchronized(var2){}
-
- String var1;
- try {
- if (this.ctb == null) {
- var1 = null;
- return var1;
- }
-
- var1 = this.ctb.getCharacterEncoding();
- } catch (Throwable var5) {
- throw var5;
- }
-
- return var1;
- }
-
- private void ensureOpen() throws IOException {
- if (this.out == null) {
- throw new IOException("Stream closed");
- }
- }
-
- public void write(int var1) throws IOException {
- char[] var2 = new char[]{(char)var1};
- this.write((char[])var2, 0, 1);
- }
-
- public void write(char[] var1, int var2, int var3) throws IOException {
- Object var4 = super.lock;
- synchronized(var4){}
-
- try {
- this.ensureOpen();
- int var6 = var2;
- int var7 = var2 + var3;
-
- while(var6 < var7) {
- boolean var8 = false;
-
- try {
- this.nextByte += this.ctb.convert(var1, var6, var7, this.field_0, this.nextByte, this.nBytes);
- var6 = var7;
- } catch (ConversionBufferFullException var12) {
- int var9 = this.ctb.nextCharIndex();
- if (var9 == var6) {
- throw new CharConversionException("Output buffer too small");
- }
-
- var6 = var9;
- var8 = true;
- this.nextByte = this.ctb.nextByteIndex();
- }
-
- if (this.nextByte >= this.nBytes || var8) {
- this.out.write(this.field_0, 0, this.nextByte);
- this.nextByte = 0;
- }
- }
- } catch (Throwable var13) {
- throw var13;
- }
-
- }
-
- public void write(String var1, int var2, int var3) throws IOException {
- char[] var4 = new char[var3];
- var1.getChars(var2, var2 + var3, var4, 0);
- this.write((char[])var4, 0, var3);
- }
-
- void flushBuffer() throws IOException {
- Object var1 = super.lock;
- synchronized(var1){}
-
- try {
- this.ensureOpen();
-
- while(true) {
- try {
- this.nextByte += this.ctb.flush(this.field_0, this.nextByte, this.nBytes);
- } catch (ConversionBufferFullException var4) {
- this.nextByte = this.ctb.nextByteIndex();
- }
-
- if (this.nextByte == 0) {
- return;
- }
-
- if (this.nextByte > 0) {
- this.out.write(this.field_0, 0, this.nextByte);
- this.nextByte = 0;
- }
- }
- } catch (Throwable var5) {
- throw var5;
- }
- }
-
- public void flush() throws IOException {
- Object var1 = super.lock;
- synchronized(var1){}
-
- try {
- this.flushBuffer();
- this.out.flush();
- } catch (Throwable var3) {
- throw var3;
- }
-
- }
-
- public void close() throws IOException {
- Object var1 = super.lock;
- synchronized(var1){}
-
- try {
- if (this.out != null) {
- this.flush();
- this.out.close();
- this.out = null;
- this.field_0 = null;
- this.ctb = null;
- return;
- }
- } catch (Throwable var4) {
- throw var4;
- }
-
- }
- }
-