bufferedreader help

this is the setup for this part of my code:

BufferedInputStream in =

new BufferedInputStream(

new FileInputStream(<path>));

BufferedOutputStream out =

new BufferedOutputStream(socket.getOutputStream());

Why wont this code read the data in increments?:

int len = 0;

while ((len = in.read(buffer)) > 0) {

out.write(buffer, 0, len);

System.out.print("#");

}.......

I figured out this code is the same as writing:

int len = in.read(buffer);

out.write(buffer, 0, len);

But I would like to write some code that can read the data in increments so that I can print a progress bar. What do I need to do?

[697 byte] By [garbleygooa] at [2007-11-27 10:17:39]
# 1

ProgressBar issues aside, does the code work?

BigDaddyLoveHandlesa at 2007-7-28 15:52:57 > top of Java-index,Java Essentials,Java Programming...
# 2

Check out the ProgressMonitorInputStream class.

camickra at 2007-7-28 15:52:57 > top of Java-index,Java Essentials,Java Programming...
# 3

Yes the code works and after looking at the code again I figured out the problem. If the file is bigger then about 52 KB the while loop is necessary or the file wont transfer correctly. Thanks for the help.

garbleygooa at 2007-7-28 15:52:57 > top of Java-index,Java Essentials,Java Programming...