new ProgressMonitorInputStream(Component p, Object m, InputStream i) : ProgressMonitorInputStream « javax.swing « Java by API






new ProgressMonitorInputStream(Component p, Object m, InputStream i)

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;

import javax.swing.JLabel;
import javax.swing.ProgressMonitorInputStream;

public class MainClass {

  public static void main(String[] a) throws Exception {
    String fileName = "BigFile.txt";
    FileInputStream fis = new FileInputStream(fileName);
    JLabel filenameLabel = new JLabel(fileName, JLabel.RIGHT);
    Object message[] = { "Reading:", filenameLabel };
    ProgressMonitorInputStream pmis = new ProgressMonitorInputStream(null, message, fis);
    InputStreamReader isr = new InputStreamReader(pmis);
    BufferedReader br = new BufferedReader(isr);
    String line;
    while ((line = br.readLine()) != null) {
      System.out.println(line);
    }
    br.close();
  }
}


           
       








Related examples in the same category

1.ProgressMonitorInputStream: available()
2.ProgressMonitorInputStream: read(byte[] b)