[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

implementing a JProgressBar



I have an executable jar that extracts files from itself. I would like to
have a JProgressBar show the progress of this. Below is the code I use for
extraction. How can I implement a JProgressBar to use this? I would like to
increment it with each "buffered IO dump".

code:

JarFile thisJar = new JarFile("some.jar");
Enumeration enum = thisJar.entries();
enum.nextElement();
File dir = null;
JarEntry je=null;
InputStream is=null;
BufferedInputStream bi=null;
FileOutputStream fos=null;
BufferedOutputStream bo=null;

/*fileList is an array of Strings each is a name
a jar entry*/
for(int i = 0;i<fileList.length;i++)
{
   String str = fileList[i].toString();

   if(str.indexOf('.',0)==-1)
   {
      dir = fileList[i].getParentFile();
dir.mkdirs();
fileList[i].mkdirs();
continue;
   }

   je = ((JarEntry)enum.nextElement());
   is = getClass().getClassLoader().getResourceAsStream(je.toString());
   bi = new BufferedInputStream(is,16384);
   fos = new FileOutputStream(fileList[i]);
   bo = new BufferedOutputStream(fos,16384);
   try
   {
      while(true)
      {
         byte [] byteArray = new byte[16384];
         int intRead = bi.read(byteArray, 0, byteArray.length);
         bo.write(byteArray, 0, intRead);
         bo.flush();
      }
   }
   catch (Exception k)
   {
      k.printStackTrace(ps);
      System.out.println("There were problems extracting the Jar!");*/
   }
   bi.close();
   bo.close();
}


Thanks in advance,

-Jason

****************************************************************************
********
Jason R. Kretzer
Software Engineer
Opinion One
Email:  jason@opone.com
Phone:  (513) 361-2771
Website:  http://alia.iwarp.com

"Make visible what, without you, might perhaps never have been seen."
--Robert Bresson
****************************************************************************
********