This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ProgressMonitor InputStream  RSS feed

 
Manuel Palacio
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
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.

/Manuel


//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");
}
}
};
t.start();
}

.......................


[This message has been edited by Manuel Palacio (edited December 01, 2000).]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!