Progress monitor -- ProgressMonitorInputStream,

Source: Internet
Author: User

Progress monitor -- ProgressMonitorInputStream,
Progress monitor -- ProgressMonitorInputStream

ProgressMonitorInputStream

You can create a progress monitor to monitor the progress of reading input streams. If it takes a while, ProgressDialog will pop up to notify the user. If you click the Cancel button, InterruptedIOException is thrown during the next read operation. When the stream is disabled, all the correct cleanup operations are performed.

The progress bar is as follows:

The Code is as follows:

1 import java. io. *; 2 3 import javax. swing. *; 4 5 public class Fuck {6 public static void main (String [] temp) {7 byte B [] = new byte [2]; 8 try {9 FileInputStream FCM = new FileInputStream ("d :\\ user. xml "); 10 ProgressMonitorInputStream in = 11 new ProgressMonitorInputStream (null," Read File ", FS); 12 while (in. read (B )! =-1) {13 String s = new String (B); 14 System. out. print (s); 15 Thread. sleep (100); 16} 17} catch (Exception e) {18 e. printStackTrace (); 19} 20} 21}
ProgressMonitorInputStream has three attributes:
Component parentComponent determines which Component the progress bar is attached
Content displayed on the object message progress bar
InputStream in byte input stream (file to be read)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.