Mercurial > hg > monetdb-java
comparison src/main/java/org/monetdb/jdbc/MonetConnection.java @ 515:7bbcff2c775b onclient
Also implement downloadTo(), and use it in FileTransferHandler
author | Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com> |
---|---|
date | Mon, 23 Aug 2021 09:43:35 +0200 (2021-08-23) |
parents | 443780d71bae |
children | 704a11b93e6b |
comparison
equal
deleted
inserted
replaced
514:443780d71bae | 515:7bbcff2c775b |
---|---|
3379 stream = server.downloadStream(); | 3379 stream = server.downloadStream(); |
3380 server.getOutputStream().flush(); | 3380 server.getOutputStream().flush(); |
3381 } | 3381 } |
3382 return stream; | 3382 return stream; |
3383 } | 3383 } |
3384 | |
3385 public void downloadTo(OutputStream stream) throws IOException { | |
3386 InputStream s = getStream(); | |
3387 byte[] buffer = new byte[65536]; | |
3388 while (true) { | |
3389 int nread = s.read(buffer); | |
3390 if (nread < 0) | |
3391 break; | |
3392 stream.write(buffer, 0, nread); | |
3393 } | |
3394 } | |
3395 | |
3384 public boolean hasBeenUsed() { | 3396 public boolean hasBeenUsed() { |
3385 return error != null || stream != null; | 3397 return error != null || stream != null; |
3386 } | 3398 } |
3387 | 3399 |
3388 public String getError() { | 3400 public String getError() { |