I'm trying to change this while loop into a for loop and I'm not getting particularly far. I am new ish to programming, so apologies if this is a trivial task.
while (read < fileBytes.length
&& (numRead = diStream.read(fileBytes, read, fileBytes.length - read)) >= 0)
{
read = read + numRead;
}
Try to use this :
start_value = //....
for (read = start_value; read < fileBytes.length
&& (numRead = diStream.read(fileBytes, read, fileBytes.length - read)) >= 0;
read += numRead) {
//Your actions
}
I'm a C# Programmer, but I will write code which is very similar to what you need.
for (int read = 0; read < fileBytes.length;) {
numRead = diStream.read(fileBytes, read, fileBytes.length - read);
if (numRead >= 0) {
read = read + numRead;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With