我写了一个方法,但是占有大量的cpu,希望大侠指教
我的代码入下:
public static boolean unJarFile(String jarFileName,String outputDirectory)
  {
    JarInputStream in=null;
    try
    {
      in=new JarInputStream(new FileInputStream(jarFileName));
      JarEntry jen;
      while((jen=in.getNextJarEntry())!=null)
      {
        if(jen.isDirectory())
        {
           String name = jen.getName();
           name = name.substring(0, name.length() - 1);
           File file = new File(outputDirectory + File.separator + name);
           file.mkdir();
        }
        else
        {
          String fname=outputDirectory + File.separator + jen.getName().substring(0,jen.getName().indexOf("/"));
          File dt=new File(fname);
          if(!dt.exists())
          {
             dt.mkdir();
          }
          File file = new File(outputDirectory + File.separator + jen.getName());
          file.createNewFile();
          FileOutputStream out = new FileOutputStream(file);
          int b;
          while ( (b = in.read()) != -1){
            out.write(b);
          }
          out.close();
        }
      }
      in.close();
    }
    catch(Exception e)
    {
      try {
        //e.printStackTrace();
        in.close();
        return false;
      }
      catch (IOException ex) {
        return false;
      }
    }
    return true;
  }
希望能有一个高效的算法