*
* The MIT License (MIT)
*
- * Copyright (C) 2017 Kevin Lamonte
+ * Copyright (C) 2019 Kevin Lamonte
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
// available. If not, we throw ReadTimeoutException.
long checkTime = System.currentTimeMillis();
while (stream.available() == 0) {
- long now = System.currentTimeMillis();
+ if (remaining > 0) {
+ return (b.length - remaining);
+ }
+ long now = System.currentTimeMillis();
synchronized (this) {
if ((now - checkTime > timeoutMillis) || (cancel == true)) {
if (cancel == true) {
if (timeoutMillis == 0) {
// Block on the read().
- return stream.read(b);
+ return stream.read(b, off, len);
}
int remaining = len;
// available. If not, we throw ReadTimeoutException.
long checkTime = System.currentTimeMillis();
while (stream.available() == 0) {
+ if (remaining > 0) {
+ return (len - remaining);
+ }
+
long now = System.currentTimeMillis();
synchronized (this) {
if ((now - checkTime > timeoutMillis) || (cancel == true)) {