comparison src/main/java/org/monetdb/jdbc/MonetConnection.java @ 579:72f4437de9be onclient

Reencode downloads if necessary
author Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
date Thu, 14 Oct 2021 16:11:52 +0200 (2021-10-14)
parents 095e896f9d7a
children 6aa38e8c0f2d
comparison
equal deleted inserted replaced
578:687034945b3f 579:72f4437de9be
3522 stream.write(buffer, 0, nread); 3522 stream.write(buffer, 0, nread);
3523 } 3523 }
3524 } 3524 }
3525 3525
3526 /** 3526 /**
3527 * Write the textual data from the server to the given {@link Writer}
3528 * @param writer
3529 */
3530 public void downloadTo(final Writer writer) throws IOException {
3531 final InputStream s = getStream();
3532 final InputStreamReader r = new InputStreamReader(s, StandardCharsets.UTF_8);
3533 final char[] buffer = new char[65536];
3534 while (true) {
3535 final int nread = r.read(buffer);
3536 if (nread < 0)
3537 break;
3538 writer.write(buffer, 0, nread);
3539 }
3540 }
3541
3542 /**
3527 * @return true if data has been received or an error has been sent. 3543 * @return true if data has been received or an error has been sent.
3528 */ 3544 */
3529 public boolean hasBeenUsed() { 3545 public boolean hasBeenUsed() {
3530 return error != null || stream != null; 3546 return error != null || stream != null;
3531 } 3547 }