1 Clazz.declarePackage ("jssun.misc");
2 Clazz.load (null, "jssun.misc.Resource", ["java.io.EOFException", "java.lang.Thread", "java.util.Arrays"], function () {
3 c$ = Clazz.decorateAsClass (function () {
5 Clazz.instantialize (this, arguments);
6 }, jssun.misc, "Resource");
7 Clazz.defineMethod (c$, "cachedInputStream",
9 if (this.cis == null) {
10 this.cis = this.getInputStream ();
13 Clazz.defineMethod (c$, "getBytes",
16 var $in = this.cachedInputStream ();
17 var isInterrupted = Thread.interrupted ();
21 len = this.getContentLength ();
24 if (Clazz.exceptionOf (iioe, java.io.InterruptedIOException)) {
25 Thread.interrupted ();
33 b = Clazz.newByteArray (0, 0);
34 if (len == -1) len = 2147483647;
38 if (pos >= b.length) {
39 bytesToRead = Math.min (len - pos, b.length + 1024);
40 if (b.length < pos + bytesToRead) {
41 b = java.util.Arrays.copyOf (b, pos + bytesToRead);
43 bytesToRead = b.length - pos;
46 cc = $in.read (b, pos, bytesToRead);
48 if (Clazz.exceptionOf (iioe, java.io.InterruptedIOException)) {
49 Thread.interrupted ();
56 if (len != 2147483647) {
57 throw new java.io.EOFException ("Detect premature EOF");
59 if (b.length != pos) {
60 b = java.util.Arrays.copyOf (b, pos);
68 if (Clazz.exceptionOf (e$$, java.io.InterruptedIOException)) {
73 } else if (Clazz.exceptionOf (e$$, java.io.IOException)) {
82 Thread.currentThread ().interrupt ();