/* * @(#)ListFits.java $Revision: 1.4 $ $Date: 2004-01-12 13:13:23 $ * * Copyright (C) 1999 European Southern Observatory * License: GNU General Public License version 2 or later */ package org.eso.fits; import java.util.*; import java.io.*; /** ListFits class provides a static main method for listing a set * of FITS keywords in FITS files. * @version $Revision: 1.4 $ $Date: 2004-01-12 13:13:23 $ * @author P.Grosbol, ESO, */ public class ListFits{ /** Static main method for listing keywords of a set of FITS files. * * @param argv First argument is a list of FITS files or directories, * second argument is a comma separated list of FITS * keywords to be listed. */ public static void main(String[] argv) { if (argv.length < 1) { System.out.println("Error: must be called with one argument"); System.exit(1); } // get list of files StringTokenizer files = new StringTokenizer(argv[0],","); // get list of keywords to list for each file String[] keys = new String[0]; if (argv.length > 1) { StringTokenizer stok = new StringTokenizer(argv[1],","); keys = new String[stok.countTokens()]; int no = 0; while (stok.hasMoreTokens()) { keys[no++] = (stok.nextToken()).toUpperCase(); } stok = null; } // go through files one by one int nofiles = 0; int nokwords = 0; long time = System.currentTimeMillis(); while (files.hasMoreTokens()) { String name = files.nextToken(); File file = new File(name); // if directory read all files in it String[] flist = new String[1]; if (file.isDirectory()) { flist = file.list(); } else { flist[0] = name; } for (int i=0; i