Example usage for javax.swing ProgressMonitorInputStream available

List of usage examples for javax.swing ProgressMonitorInputStream available

Introduction

In this page you can find the example usage for javax.swing ProgressMonitorInputStream available.

Prototype

public int available() throws IOException 

Source Link

Document

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.

Usage

From source file:Main.java

public static void main(String args[]) throws Exception {
    ProgressMonitorInputStream monitor;

    monitor = new ProgressMonitorInputStream(null, "Loading ", new FileInputStream("fileName.txt"));

    while (monitor.available() > 0) {
        byte[] data = new byte[38];
        monitor.read(data);/*w  ww.j  av  a2 s  .  co m*/
        System.out.write(data);
    }
}

From source file:Main.java

public static void main(String args[]) {
    ProgressMonitorInputStream monitor;
    try {//from w w  w. ja v a  2 s .c  om
        monitor = new ProgressMonitorInputStream(null, "Loading ", new FileInputStream("yourFile.dat"));
        while (monitor.available() > 0) {
            byte[] data = new byte[38];
            monitor.read(data);
            System.out.write(data);
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Unable to find file: yourFile.dat", "Error",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:MainClass.java

public MainClass(String filename) {
    ProgressMonitorInputStream monitor;
    try {//from   ww w .  j  a va  2s . com
        monitor = new ProgressMonitorInputStream(null, "Loading " + filename, new FileInputStream(filename));
        while (monitor.available() > 0) {
            byte[] data = new byte[38];
            monitor.read(data);
            System.out.write(data);
        }
    } catch (FileNotFoundException e) {
        JOptionPane.showMessageDialog(null, "Unable to find file: " + filename, "Error",
                JOptionPane.ERROR_MESSAGE);
    } catch (IOException e) {
        ;
    }
}

From source file:ProgressMonitorInputExample.java

public ProgressMonitorInputExample(String filename) {
    ProgressMonitorInputStream monitor;
    try {//from w w w  .  ja v a 2 s.c  o m
        monitor = new ProgressMonitorInputStream(null, "Loading " + filename, new FileInputStream(filename));
        while (monitor.available() > 0) {
            byte[] data = new byte[38];
            monitor.read(data);
            System.out.write(data);
        }
    } catch (FileNotFoundException e) {
        JOptionPane.showMessageDialog(null, "Unable to find file: " + filename, "Error",
                JOptionPane.ERROR_MESSAGE);
    } catch (IOException e) {
        ;
    }
}