jdk/src/share/classes/com/sun/org/apache/xml/internal/security/utils/UnsyncBufferedOutputStream.java
equal
deleted
inserted
replaced
31 public class UnsyncBufferedOutputStream extends OutputStream { |
31 public class UnsyncBufferedOutputStream extends OutputStream { |
32 final OutputStream out; |
32 final OutputStream out; |
33 |
33 |
34 final byte[] buf; |
34 final byte[] buf; |
35 static final int size=8*1024; |
35 static final int size=8*1024; |
36 private static ThreadLocal bufCahce = new ThreadLocal() { |
36 private static ThreadLocal<byte[]> bufCahce = new ThreadLocal<byte[]>() { |
37 protected synchronized Object initialValue() { |
37 protected synchronized byte[] initialValue() { |
38 return new byte[size]; |
38 return new byte[size]; |
39 } |
39 } |
40 }; |
40 }; |
41 int pointer=0; |
41 int pointer=0; |
42 /** |
42 /** |
43 * Creates a buffered output stream without synchronization |
43 * Creates a buffered output stream without synchronization |
44 * @param out the outputstream to buffer |
44 * @param out the outputstream to buffer |
45 */ |
45 */ |
46 public UnsyncBufferedOutputStream(OutputStream out) { |
46 public UnsyncBufferedOutputStream(OutputStream out) { |
47 buf=(byte[])bufCahce.get(); |
47 buf=bufCahce.get(); |
48 this.out=out; |
48 this.out=out; |
49 } |
49 } |
50 |
50 |
51 /** @inheritDoc */ |
51 /** @inheritDoc */ |
52 public void write(byte[] arg0) throws IOException { |
52 public void write(byte[] arg0) throws IOException { |