Mercurial Hosting > luan
annotate src/org/eclipse/jetty/util/IO.java @ 1022:3718afd99988
HttpHeaders uses StringCache
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 01 Nov 2016 01:04:46 -0600 |
parents | 2bb375e94f64 |
children |
rev | line source |
---|---|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
2 // ======================================================================== |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
4 // ------------------------------------------------------------------------ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
5 // All rights reserved. This program and the accompanying materials |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
6 // are made available under the terms of the Eclipse Public License v1.0 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
7 // and Apache License v2.0 which accompanies this distribution. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
8 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
9 // The Eclipse Public License is available at |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
10 // http://www.eclipse.org/legal/epl-v10.html |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
11 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
12 // The Apache License v2.0 is available at |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
13 // http://www.opensource.org/licenses/apache2.0.php |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
14 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
15 // You may elect to redistribute this code under either of these licenses. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
16 // ======================================================================== |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
17 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
18 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
19 package org.eclipse.jetty.util; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
20 import java.io.ByteArrayOutputStream; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
21 import java.io.Closeable; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
22 import java.io.File; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
23 import java.io.FileInputStream; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
24 import java.io.FileOutputStream; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
25 import java.io.IOException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
26 import java.io.InputStream; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
27 import java.io.InputStreamReader; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
28 import java.io.OutputStream; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
29 import java.io.PrintWriter; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
30 import java.io.Reader; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
31 import java.io.StringWriter; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
32 import java.io.Writer; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
33 |
820
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
34 import org.slf4j.Logger; |
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
35 import org.slf4j.LoggerFactory; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
36 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
37 /* ======================================================================== */ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
38 /** IO Utilities. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
39 * Provides stream handling utilities in |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
40 * singleton Threadpool implementation accessed by static members. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
41 */ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
42 public class IO |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
43 { |
862
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
44 private static final Logger LOG = LoggerFactory.getLogger(IO.class); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
45 |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
46 /* ------------------------------------------------------------------- */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
47 private static int bufferSize = 64*1024; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
48 |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
49 /* ------------------------------------------------------------------- */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
50 /** Copy Stream in to Stream out until EOF or exception. |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
51 */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
52 public static void copy(InputStream in, OutputStream out) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
53 throws IOException |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
54 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
55 copy(in,out,-1); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
56 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
57 |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
58 /* ------------------------------------------------------------------- */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
59 /** Copy Reader to Writer out until EOF or exception. |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
60 */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
61 public static void copy(Reader in, Writer out) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
62 throws IOException |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
63 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
64 copy(in,out,-1); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
65 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
66 |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
67 /* ------------------------------------------------------------------- */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
68 /** Copy Stream in to Stream for byteCount bytes or until EOF or exception. |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
69 */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
70 public static void copy(InputStream in, |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
71 OutputStream out, |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
72 long byteCount) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
73 throws IOException |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
74 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
75 byte buffer[] = new byte[bufferSize]; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
76 int len=bufferSize; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
77 |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
78 if (byteCount>=0) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
79 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
80 while (byteCount>0) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
81 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
82 int max = byteCount<bufferSize?(int)byteCount:bufferSize; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
83 len=in.read(buffer,0,max); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
84 |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
85 if (len==-1) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
86 break; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
87 |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
88 byteCount -= len; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
89 out.write(buffer,0,len); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
90 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
91 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
92 else |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
93 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
94 while (true) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
95 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
96 len=in.read(buffer,0,bufferSize); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
97 if (len<0 ) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
98 break; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
99 out.write(buffer,0,len); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
100 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
101 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
102 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
103 |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
104 /* ------------------------------------------------------------------- */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
105 /** Copy Reader to Writer for byteCount bytes or until EOF or exception. |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
106 */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
107 public static void copy(Reader in, |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
108 Writer out, |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
109 long byteCount) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
110 throws IOException |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
111 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
112 char buffer[] = new char[bufferSize]; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
113 int len=bufferSize; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
114 |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
115 if (byteCount>=0) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
116 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
117 while (byteCount>0) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
118 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
119 if (byteCount<bufferSize) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
120 len=in.read(buffer,0,(int)byteCount); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
121 else |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
122 len=in.read(buffer,0,bufferSize); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
123 |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
124 if (len==-1) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
125 break; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
126 |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
127 byteCount -= len; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
128 out.write(buffer,0,len); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
129 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
130 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
131 else if (out instanceof PrintWriter) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
132 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
133 PrintWriter pout=(PrintWriter)out; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
134 while (!pout.checkError()) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
135 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
136 len=in.read(buffer,0,bufferSize); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
137 if (len==-1) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
138 break; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
139 out.write(buffer,0,len); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
140 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
141 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
142 else |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
143 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
144 while (true) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
145 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
146 len=in.read(buffer,0,bufferSize); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
147 if (len==-1) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
148 break; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
149 out.write(buffer,0,len); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
150 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
151 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
152 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
153 |
862
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
154 /* ------------------------------------------------------------ */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
155 /** Copy files or directories |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
156 * @param from |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
157 * @param to |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
158 * @throws IOException |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
159 */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
160 public static void copy(File from,File to) throws IOException |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
161 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
162 if (from.isDirectory()) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
163 copyDir(from,to); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
164 else |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
165 copyFile(from,to); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
166 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
167 |
862
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
168 /* ------------------------------------------------------------ */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
169 public static void copyDir(File from,File to) throws IOException |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
170 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
171 if (to.exists()) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
172 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
173 if (!to.isDirectory()) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
174 throw new IllegalArgumentException(to.toString()); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
175 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
176 else |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
177 to.mkdirs(); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
178 |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
179 File[] files = from.listFiles(); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
180 if (files!=null) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
181 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
182 for (int i=0;i<files.length;i++) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
183 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
184 String name = files[i].getName(); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
185 if (".".equals(name) || "..".equals(name)) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
186 continue; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
187 copy(files[i],new File(to,name)); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
188 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
189 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
190 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
191 |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
192 /* ------------------------------------------------------------ */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
193 public static void copyFile(File from,File to) throws IOException |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
194 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
195 FileInputStream in=new FileInputStream(from); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
196 FileOutputStream out=new FileOutputStream(to); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
197 copy(in,out); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
198 in.close(); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
199 out.close(); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
200 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
201 |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
202 |
862
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
203 /* ------------------------------------------------------------ */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
204 /** |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
205 * closes any {@link Closeable} |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
206 * |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
207 * @param c the closeable to close |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
208 */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
209 public static void close(Closeable c) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
210 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
211 try |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
212 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
213 if (c != null) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
214 c.close(); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
215 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
216 catch (IOException e) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
217 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
218 LOG.trace("",e); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
219 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
220 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
221 |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
222 /** |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
223 * closes an input stream, and logs exceptions |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
224 * |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
225 * @param is the input stream to close |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
226 */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
227 public static void close(InputStream is) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
228 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
229 try |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
230 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
231 if (is != null) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
232 is.close(); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
233 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
234 catch (IOException e) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
235 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
236 LOG.trace("",e); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
237 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
238 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
239 |
862
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
240 /** |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
241 * closes a reader, and logs exceptions |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
242 * |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
243 * @param reader the reader to close |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
244 */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
245 public static void close(Reader reader) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
246 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
247 try |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
248 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
249 if (reader != null) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
250 reader.close(); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
251 } catch (IOException e) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
252 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
253 LOG.trace("",e); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
254 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
255 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
256 |
862
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
257 /** |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
258 * closes a writer, and logs exceptions |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
259 * |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
260 * @param writer the writer to close |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
261 */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
262 public static void close(Writer writer) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
263 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
264 try |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
265 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
266 if (writer != null) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
267 writer.close(); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
268 } catch (IOException e) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
269 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
270 LOG.trace("",e); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
271 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
272 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
273 |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
274 /* ------------------------------------------------------------ */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
275 /** |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
276 * closes an output stream, and logs exceptions |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
277 * |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
278 * @param os the output stream to close |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
279 */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
280 public static void close(OutputStream os) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
281 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
282 try |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
283 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
284 if (os != null) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
285 os.close(); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
286 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
287 catch (IOException e) |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
288 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
289 LOG.trace("",e); |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
290 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
291 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
292 |
862
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
293 /* ------------------------------------------------------------ */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
294 /** |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
295 * @return An outputstream to nowhere |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
296 */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
297 public static InputStream getClosedStream() |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
298 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
299 return __closedStream; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
300 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
301 |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
302 /* ------------------------------------------------------------ */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
303 /* ------------------------------------------------------------ */ |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
304 private static class ClosedIS extends InputStream |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
305 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
306 @Override |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
307 public int read() throws IOException |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
308 { |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
309 return -1; |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
310 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
311 } |
2bb375e94f64
simplify jetty.util.IO
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
312 private static ClosedIS __closedStream = new ClosedIS(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
313 } |