Changeset 4009
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/examples/webservices/src/net/sf/basedb/ws/example/Main.java
r3984 r4009 31 31 32 32 import org.apache.axis2.AxisFault; 33 import org.apache.commons.io.IOUtils; 33 34 34 35 import net.sf.basedb.info.DataFileTypeInfo; … … 270 271 InputStream in = rc.downloadRawDataByType(info.getId(), fileType.getExternalId()); 271 272 OutputStream out = new FileOutputStream(downloadTo); 272 copy(in, out);273 IOUtils.copy(in, out); 273 274 out.close(); 274 275 in.close(); … … 282 283 System.out.println(""); 283 284 } 284 } 285 } 286 287 /** 288 Copy from InputStream to OutputStream 289 */ 290 public long copy(InputStream in, OutputStream out) 291 throws IOException 292 { 293 int bytes = 0; 294 long totalBytes = 0; 295 byte[] buffer = new byte[1024]; 296 while (bytes != -1) // -1 = end of stream 297 { 298 bytes = in.read(buffer, 0, buffer.length); 299 if (bytes > 0) 300 { 301 totalBytes += bytes; 302 out.write(buffer, 0, bytes); 303 } 304 } 305 return totalBytes; 306 } 307 285 } 286 } 308 287 309 288 }
Note: See TracChangeset
for help on using the changeset viewer.