Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

ProgressMonitorInputStream

Posted on 2003-03-12
14
Medium Priority
?
325 Views
Last Modified: 2010-03-31
Can anyone please tell me how to assign ProgressMonitorInputStream to the following code? So that we can see how far the process has completed.
     
ArrayList images=new ArrayList();

     ZipInputStream zin = new ZipInputStream(new FileInputStream(filename));
     ZipEntry zent=     zin.getNextEntry();
     JPEGImageDecoder decoder1=JPEGCodec.createJPEGDecoder(zin);
     BufferedImage bi1=decoder1.decodeAsBufferedImage();
     AffineTransformOp aop1=new AffineTransformOp(new AffineTransform(), AffineTransformOp.TYPE_BILINEAR);
     BufferedImageFilter bif1=new BufferedImageFilter(aop1);
     FilteredImageSource fsource1=new FilteredImageSource(bi1.getSource(), bif1);
     Image img1=Toolkit.getDefaultToolkit().createImage(fsource1);



     images.add(new ImageIcon(img1, "Map"));
     zin.closeEntry();
     zent=zin.getNextEntry();

     while(! zent .getName().equals("data.ser"))
         {
          JPEGImageDecoder decoder2=JPEGCodec.createJPEGDecoder(zin);
          BufferedImage bi2=decoder2.decodeAsBufferedImage();
          AffineTransformOp aop2=new AffineTransformOp(new AffineTransform(), AffineTransformOp.TYPE_BILINEAR);
          BufferedImageFilter bif2=new BufferedImageFilter(aop2);
          FilteredImageSource fsource2=new FilteredImageSource(bi2.getSource(), bif2);
          Image img2=Toolkit.getDefaultToolkit().createImage(fsource2);
          String imgName=new File(zent.getName()).getName();
          images.add(new ImageIcon(img2, imgName.endsWith(".jpg")?imgName.substring(0,imgName.length()-4):imgName));
          zent=zin.getNextEntry();
         }

     ObjectInputStream oin = new ObjectInputStream(zin);

     Object data= oin.readObject();

     zin.closeEntry();
0
Comment
Question by:csound
  • 5
  • 5
  • 4
14 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 8123854
It would be more appropriate IMHO to use a progress monitor on zip entries rather than use ProgressMonitorInputStream
0
 
LVL 92

Accepted Solution

by:
objects earned 400 total points
ID: 8123913
ZipInputStream zin = new ZipInputStream(
   new ProgressMonitorInputStream(comp, "Unzipping...",
new FileInputStream(filename)));
   
0
 
LVL 92

Expert Comment

by:objects
ID: 8123914
ZipInputStream zin = new ZipInputStream(
   new ProgressMonitorInputStream(comp, "Unzipping...",
new FileInputStream(filename)));
   
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:csound
ID: 8123928
-> CEHJ
what's IMHO?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8123946
in my humble opinion. But give it a try with objects' suggestion first.
0
 

Author Comment

by:csound
ID: 8124040
The progress monitor does not get displayed..
0
 
LVL 92

Expert Comment

by:objects
ID: 8124058
It may not need to, it only displays if the reading takes a while.
How big is your zip file?

http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html

0
 

Author Comment

by:csound
ID: 8124063
The progress monitor does not get displayed..
0
 
LVL 92

Expert Comment

by:objects
ID: 8124070
You can adjust the settings using the ProgressMonitor class.
0
 

Author Comment

by:csound
ID: 8124077
The file size was about 70K.
0
 

Author Comment

by:csound
ID: 8124112
So I have to
ProgressMonitorInputStream pmi=new ProgressMonitorInputStream(comp, "Unzipping...",
new FileInputStream(filename));

ProgressMonitor pm=pmi.getProgressMonitor();
//do some setting

ZipInputStream zin = new ZipInputStream(
pmi);

Is this correct?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8124127
It seems to me the processing overhead is confined to what's going on in your loop, which is a good reason why the progress monitor should not be attached to the input stream
0
 
LVL 92

Expert Comment

by:objects
ID: 8124153
csound> Is this correct?

yes

cehj> It seems to me the processing overhead is confined to
cehj> what's going on in your loop, which is a good reason why
cehj> the progress monitor should not be attached to the input stream

But the loop is reading the stream?

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 8124208
I suppose if the next read of the stream is going to have to wait on the processing, then it can be made to amount to the same thing yes.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month15 days, 13 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question