Changeset 6227


Ignore:
Timestamp:
05/04/10 16:58:53 (10 years ago)
Author:
curtis
Message:

Fix problems with available() and readString(int).

Fixes an indirect bug with OMEXMLReader.isThisType
that was preventing .fake files from working.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/common/src/loci/common/RandomAccessInputStream.java

    r6190 r6227  
    322322  } 
    323323 
    324   /** Read a string of length n. */ 
     324  /** Read a string of up to length n. */ 
    325325  public String readString(int n) throws IOException { 
     326    int avail = available(); 
     327    if (n > avail) n = avail; 
    326328    byte[] b = new byte[n]; 
    327329    readFully(b); 
     
    404406 
    405407  public int available() throws IOException { 
    406     long fp = getFilePointer(); 
    407     if (fp > Integer.MAX_VALUE) return Integer.MAX_VALUE; 
    408     return (int) fp; 
     408    long remain = length() - getFilePointer(); 
     409    if (remain > Integer.MAX_VALUE) remain = Integer.MAX_VALUE; 
     410    return (int) remain; 
    409411  } 
    410412 
Note: See TracChangeset for help on using the changeset viewer.