Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
changing while loops to for loops

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;
}
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

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

}
over 4 years ago · Santiago Trujillo Report

0

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;
    }
}
over 4 years ago · Santiago Trujillo Report

0

for(numRead = diStream.read(fileBytes, read, fileBytes.length - read);
read < fileBytes.length && numRead >= 0;
numRead = diStream.read(fileBytes, read, fileBytes.length - read)) {
      read = read + numRead;
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!