public static void main(String[] args)  {
		if (args.length != 1) {
			System.out.println("This simple demo utility must be called with a JPEG file. For example:");
			System.out.println("    bin/jshowsize.sh myWonderfulJpegFile.jpg");
			return;
		}
		
        JpegData parser = new JpegData();
		try {
			RandomAccessFile file = new RandomAccessFile(args[0], "r");
			parser.read(file);
			if ( ! parser.isValid()) {
				System.out.println("INVALID FILE: " + args[0]);
			}
			for (DataItem sgmt : parser) {
				if (sgmt instanceof JfifSegment) {
					JfifSegment jfif = (JfifSegment) sgmt;
					String units;
					switch (jfif.getUnits()) {
						case 0:
							units = "px";
							break;
						case 1:
							units = "in";
							break;
						case 2:
							units = "cm";
							break;
						default:
							units = "(unknown units)";
							break;

					}
					System.out.println("Width: " + jfif.getXDensity() + units);
					System.out.println("Height: " + jfif.getYDensity() + units);
				}
			}
		} catch (Exception ex) {
			System.out.println("EXCEPTION: " + ex);
			ex.printStackTrace();
		}
    }