예제 #1
0
 /**
  * To use this class as a command line application, give it either some file names as parameters
  * (information on them will be printed to standard output, one line per file) or call it with no
  * parameters. It will then check data given to it via standard input.
  *
  * @param args the program arguments which must be file names
  */
 public static void main(String[] args) {
   ImageInfo imageInfo = new ImageInfo();
   imageInfo.setDetermineImageNumber(true);
   boolean verbose = determineVerbosity(args);
   if (args.length == 0) {
     run(null, System.in, imageInfo, verbose);
   } else {
     int index = 0;
     while (index < args.length) {
       InputStream in = null;
       try {
         String name = args[index++];
         System.out.print(name + ";"); // $NON-NLS-1$
         if (name.startsWith("http://")) { // $NON-NLS-1$
           in = new URL(name).openConnection().getInputStream();
         } else {
           in = new FileInputStream(name);
         }
         run(name, in, imageInfo, verbose);
         in.close();
       } catch (Exception e) {
         System.out.println(e);
         try {
           in.close();
         } catch (Exception ee) {
         }
       }
     }
   }
 }
예제 #2
0
 private static void run(String sourceName, InputStream in, ImageInfo imageInfo, boolean verbose) {
   imageInfo.setInput(in);
   imageInfo.setDetermineImageNumber(false);
   imageInfo.setCollectComments(verbose);
   if (imageInfo.check()) {
     print(sourceName, imageInfo, verbose);
   }
 }