• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ProgressMonitor InputStream

Manuel Palacio
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has become an unsolvable problem although it does not affect the functionality of the method.
The ProgressMonitorStream does not pop up! Not even with mp3 files over 8 meg! I've tried in different ways. If I read the bytes one by one with read() and not with read(byte[],int,int) then it pops up. But that's much slower and seems unnecessary.
I would greatly appreciate any suggestions to make it work.


//some method(){
final JFileChooser filechooser=new JFileChooser();
int returnVal = filechooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {

Thread t=new Thread() {

public void run() {

try {

File file = filechooser.getSelectedFile();
FileInputStream filestream=new FileInputStream(file);
int size=filestream.available();
ProgressMonitorInputStream progress=new ProgressMonitorInputStream(Client.this,"Reading file"+file.getName(),filestream);
BufferedInputStream instream=new BufferedInputStream(progress);
byte[]arr=new byte[size];
int filesize=instream.read(arr,0,size);
send(new FileMessage(getUser(),getSelectedUser(),"file",arr));

}catch(IOException e) {
System.out.println("Problems reading file");


[This message has been edited by Manuel Palacio (edited December 01, 2000).]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic