I had coded this once before not too long ago for someone in this forum and it worked great but for some reason it dosen't seem to work anymore. The only diffrence is that i am using Readers and Writers instead of Streams but i don't think that should't matter in this case. Has anyone use this class before?
Code:// Created on 11/24/01 import java.awt.*; import javax.swing.*; import java.io.*; public class FileMonitor{ private ProgressMonitor pm; private char[] buffer; private int counter; private int charread; public FileMonitor(Container con,String filename, Reader in,Writer out){ try{ buffer = new char[(char)filename.length()]; pm = new ProgressMonitor(con,"Monitoring Progress", "Initializing...", 0,100); pm.setMillisToPopup(0); // default value is 2000 pm.setMillisToDecideToPopup(0); synchronized (in) { synchronized (out) { while(true){ charread = in.read(buffer); if(charread == -1) break; counter += 1; pm.setProgress(counter); pm.setNote(" Operation is " + counter + "% complete"); out.write(buffer, 0, charread); } } }




Reply With Quote