Changeset 5083 for trunk/utils


Ignore:
Timestamp:
05/06/09 10:49:24 (11 years ago)
Author:
melissa
Message:

Cleaned up ExtractFlexMetadata utility.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/utils/ExtractFlexMetadata.java

    r5080 r5083  
    11// 
    2 // ConvertToOmeTiff.java 
     2// ExtractFlexMetadata.java 
    33// 
    44 
    5 import java.awt.image.BufferedImage; 
    65import java.io.File; 
    76import java.io.FileWriter; 
    87 
    98import loci.common.RandomAccessInputStream; 
    10 import loci.formats.ImageReader; 
    11 import loci.formats.MetadataTools; 
    129import loci.formats.TiffTools; 
    13 import loci.formats.in.FlexReader; 
    14 import loci.formats.in.TiffReader; 
    15 import loci.formats.meta.MetadataRetrieve; 
    16 import loci.formats.meta.MetadataStore; 
    17 import loci.formats.out.OMETiffWriter; 
    1810 
    19 /** Converts the given files to OME-TIFF format. */ 
    20 public class ExtractFlexMetdata { 
     11/** Extracts the XML metadata from a Flex file. */ 
     12public class ExtractFlexMetadata { 
    2113 
    2214  public static void main(String[] args) throws Exception { 
    2315    File dir; 
    24     if (args.length != 1 || !(dir=new File(args[0])).canRead()) { 
     16    if (args.length != 1 || !(dir = new File(args[0])).canRead()) { 
    2517      System.out.println("Usage: java ExtractFlexMetdata dir"); 
    2618      return; 
    2719    } 
    28     for(File file:dir.listFiles()) { 
    29       if(file.getName().endsWith(".flex"));{ 
    30       String id=file.getPath(); 
    31       int dot = id.lastIndexOf("."); 
    32       String outId = (dot >= 0 ? id.substring(0, dot) : id) + ".xml"; 
    33       String xml = (String) TiffTools.getIFDValue(TiffTools.getIFDs(new RandomAccessInputStream(id))[0], 
     20    for (File file:dir.listFiles()) { 
     21      if (file.getName().endsWith(".flex")) { 
     22        String id = file.getPath(); 
     23        int dot = id.lastIndexOf("."); 
     24        String outId = (dot >= 0 ? id.substring(0, dot) : id) + ".xml"; 
     25        RandomAccessInputStream in = new RandomAccessInputStream(id); 
     26        String xml = (String) TiffTools.getIFDValue(TiffTools.getIFDs(in)[0], 
    3427          65200, true, String.class); 
    35       FileWriter writer =new FileWriter(new File(outId)); 
    36       writer.write(xml); 
    37       writer.close(); 
    38       System.out.println("Writing header of: "+id); 
    39        
     28        in.close(); 
     29        FileWriter writer = new FileWriter(new File(outId)); 
     30        writer.write(xml); 
     31        writer.close(); 
     32        System.out.println("Writing header of: " + id); 
    4033      } 
    4134    } 
Note: See TracChangeset for help on using the changeset viewer.