Changeset 5875 for branches/cleanup


Ignore:
Timestamp:
02/02/10 04:55:02 (10 years ago)
Author:
callan
Message:
  • Adding ByteBuffer read/write capabilities to the RA streams
  • Removed a bit of superfluous code from RandomAccessInputStream
Location:
branches/cleanup/components/common/src/loci/common
Files:
2 edited

Legend:

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

    r5858 r5875  
    2828import java.io.InputStream; 
    2929import java.io.InputStreamReader; 
     30import java.nio.ByteBuffer; 
    3031import java.nio.ByteOrder; 
    3132 
     
    223224    long loc = 0; 
    224225    while (loc < maxLen) { 
    225       long pos = startPos + loc; 
    226       int num = blockSize; 
    227       if (pos + blockSize > inputLen) num = (int) (inputLen - pos); 
    228  
    229226      // if we're not saving the string, drop any old, unnecessary output 
    230227      if (!saveString) { 
     
    370367  } 
    371368 
     369  /** Read bytes from the stream into the given buffer. */ 
     370  public int read(ByteBuffer buf) throws IOException { 
     371    return raf.read(buf); 
     372  } 
     373 
     374  /** 
     375   * Read n bytes from the stream into the given buffer at the specified offset. 
     376   */ 
     377  public int read(ByteBuffer buf, int offset, int n) throws IOException { 
     378    return raf.read(buf, offset, n); 
     379  } 
     380 
    372381  /** Read bytes from the stream into the given array. */ 
    373382  public void readFully(byte[] array) throws IOException { 
  • branches/cleanup/components/common/src/loci/common/RandomAccessOutputStream.java

    r5858 r5875  
    2727import java.io.IOException; 
    2828import java.io.OutputStream; 
     29import java.nio.ByteBuffer; 
    2930import java.nio.ByteOrder; 
    3031 
     
    107108  } 
    108109 
     110  /** 
     111   * Writes bytes to the stream from the given buffer. 
     112   * @param b Source buffer to read data from. 
     113   * @throws IOException If there is an error writing to the stream. 
     114   */ 
     115  public void write(ByteBuffer b) throws IOException { 
     116    outputFile.write(b); 
     117  } 
     118 
     119  /** 
     120   * @param b Source buffer to read data from. 
     121   * @param off Offset within the buffer to start reading from. 
     122   * @param len Number of bytes to read. 
     123   * @throws IOException If there is an error writing to the stream. 
     124   */ 
     125  public void write(ByteBuffer b, int off, int len) throws IOException { 
     126    outputFile.write(b, off, len); 
     127  } 
     128 
    109129  /* @see java.io.DataOutput#write(int) */ 
    110130  public void write(int b) throws IOException { 
Note: See TracChangeset for help on using the changeset viewer.