Re: GZip

Hi Kevin,

Looking at the code in the visad.data.visad package, it appears
that VisADForm.readData() uses visad.data.visad.BinaryReader.
I believe you could use code like the following:

public static FieldImpl readGZipFile(String filename)
  throws IOException, VisADException
{
  BinaryReader reader = new BinaryReader(
    new GZIPInputStream(new FileInputStream(filename)));
  return (FieldImpl) reader.getData();
}

I'm not sure about visad.data.netcdf.Plain though.
Unfortunately, there is no standard API in VisAD for importing
data from InputStreams or InputStreamReaders. Certain file
forms such as VisADForm have implemented it in various ways,
but after a brief glance at Plain, I didn't see a way to do it
for netCDF.

-Curtis

At 11:53 AM 3/12/2004, Kevin Manross wrote:

>Greetings,
>
>In an attempt to reduce the size of the files required for my application, I 
>would like to gzip them and then unzip and read one file at a time.
>
>Can this be done "on the fly" and then read into Plain.open() and/or 
>VisADForm.open()?
>
>Something like
>
>
>>  public static FieldImpl readGZipFile(String Filename)
>>  {
>>    FieldImpl r_field;
>>    visad.data.visad.VisADForm input = new visad.data.visad.VisADForm(true);
>>    try
>>    {
>>      r_field = (FieldImpl) input.readData(
>>                                             new 
>> visad.data.visad.BinaryReader(
>>                                             new GZIPInputStream(
>>                                             new FileInputStream(Filename) ) )
>>                                           );
>>    }
>>    catch (Exception ioe)
>>    { System.err.println("TerrainBlockage (readGZipFile): " + ioe); }
>>    return r_field;
>>  }
>
>
>I've tried this and since readData() is "package private" it will not compile 
>(blatantly showing my Java ignorance  ;-)
>
>
>Many thanks!!
>
>-kevin.
>
>
>
>
>-- 
>+------------------------------------------------------------+
>Kevin L. Manross        [KD5MYD] <><           (405)-366-0557
>CIMMS Research Associate               kevin.manross@xxxxxxxx
>[NSSL-WRDD/SWATN]           http://www.cimms.ou.edu/~kmanross
>
>"My opinions are my own and not representative of CIMMS, NSSL,
> NOAA or any affiliates"
>+------------------------------------------------------------+
>


  • References:
    • GZip
      • From: Kevin Manross
  • 2004 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: