Index: trunk/src/com/drew/lang/BufferBoundsException.java
===================================================================
--- trunk/src/com/drew/lang/BufferBoundsException.java	(revision 6127)
+++ trunk/src/com/drew/lang/BufferBoundsException.java	(revision 8132)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2002-2012 Drew Noakes
+ * Copyright 2002-2015 Drew Noakes
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,26 +16,24 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 
 package com.drew.lang;
 
-import com.drew.lang.annotations.NotNull;
-
 import java.io.IOException;
 
 /**
- * A checked replacement for IndexOutOfBoundsException.  Used by BufferReader.
- * 
- * @author Drew Noakes http://drewnoakes.com
+ * A checked replacement for {@link IndexOutOfBoundsException}.  Used by {@link RandomAccessReader}.
+ *
+ * @author Drew Noakes https://drewnoakes.com
  */
-public final class BufferBoundsException extends Exception
+public final class BufferBoundsException extends IOException
 {
     private static final long serialVersionUID = 2911102837808946396L;
 
-    public BufferBoundsException(@NotNull byte[] buffer, int index, int bytesRequested)
+    public BufferBoundsException(int index, int bytesRequested, long bufferLength)
     {
-        super(getMessage(buffer, index, bytesRequested));
+        super(getMessage(index, bytesRequested, bufferLength));
     }
 
@@ -45,16 +43,17 @@
     }
 
-    public BufferBoundsException(final String message, final IOException innerException)
-    {
-        super(message, innerException);
-    }
-
-    private static String getMessage(@NotNull byte[] buffer, int index, int bytesRequested)
+    private static String getMessage(int index, int bytesRequested, long bufferLength)
     {
         if (index < 0)
-            return String.format("Attempt to read from buffer using a negative index (%s)", index);
+            return String.format("Attempt to read from buffer using a negative index (%d)", index);
 
-        return String.format("Attempt to read %d byte%s from beyond end of buffer (requested index: %d, max index: %d)",
-                bytesRequested, bytesRequested==1?"":"s", index, buffer.length - 1);
+        if (bytesRequested < 0)
+            return String.format("Number of requested bytes cannot be negative (%d)", bytesRequested);
+
+        if ((long)index + (long)bytesRequested - 1L > (long)Integer.MAX_VALUE)
+            return String.format("Number of requested bytes summed with starting index exceed maximum range of signed 32 bit integers (requested index: %d, requested count: %d)", index, bytesRequested);
+
+        return String.format("Attempt to read from beyond end of underlying data source (requested index: %d, requested count: %d, max index: %d)",
+                index, bytesRequested, bufferLength - 1);
     }
 }
Index: trunk/src/com/drew/lang/BufferReader.java
===================================================================
--- trunk/src/com/drew/lang/BufferReader.java	(revision 6127)
+++ 	(revision )
@@ -1,145 +1,0 @@
-/*
- * Copyright 2002-2012 Drew Noakes
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- *
- * More information about this project is available at:
- *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
- */
-
-package com.drew.lang;
-
-import com.drew.lang.annotations.NotNull;
-
-public interface BufferReader
-{
-    /**
-     * Returns the length of the buffer.  This value represents the total number of bytes in the underlying source.
-     *
-     * @return The number of bytes in the buffer.
-     */
-    long getLength();
-
-    /**
-     * Sets the endianness of this reader.
-     * <ul>
-     * <li><code>true</code> for Motorola (or big) endianness</li>
-     * <li><code>false</code> for Intel (or little) endianness</li>
-     * </ul>
-     *
-     * @param motorolaByteOrder <code>true</code> for motorola/big endian, <code>false</code> for intel/little endian
-     */
-    void setMotorolaByteOrder(boolean motorolaByteOrder);
-
-    /**
-     * Gets the endianness of this reader.
-     * <ul>
-     * <li><code>true</code> for Motorola (or big) endianness</li>
-     * <li><code>false</code> for Intel (or little) endianness</li>
-     * </ul>
-     */
-    boolean isMotorolaByteOrder();
-
-    /**
-     * Returns an unsigned 8-bit int calculated from one byte of data at the specified index.
-     *
-     * @param index position within the data buffer to read byte
-     * @return the 8 bit int value, between 0 and 255
-     * @throws BufferBoundsException the buffer does not contain enough bytes to service the request, or index is negative
-     */
-    short getUInt8(int index) throws BufferBoundsException;
-
-    /**
-     * Returns a signed 8-bit int calculated from one byte of data at the specified index.
-     *
-     * @param index position within the data buffer to read byte
-     * @return the 8 bit int value, between 0x00 and 0xFF
-     * @throws BufferBoundsException the buffer does not contain enough bytes to service the request, or index is negative
-     */
-    byte getInt8(int index) throws BufferBoundsException;
-
-    /**
-     * Returns an unsigned 16-bit int calculated from two bytes of data at the specified index.
-     *
-     * @param index position within the data buffer to read first byte
-     * @return the 16 bit int value, between 0x0000 and 0xFFFF
-     * @throws BufferBoundsException the buffer does not contain enough bytes to service the request, or index is negative
-     */
-    int getUInt16(int index) throws BufferBoundsException;
-
-    /**
-     * Returns a signed 16-bit int calculated from two bytes of data at the specified index (MSB, LSB).
-     *
-     * @param index position within the data buffer to read first byte
-     * @return the 16 bit int value, between 0x0000 and 0xFFFF
-     * @throws BufferBoundsException the buffer does not contain enough bytes to service the request, or index is negative
-     */
-    short getInt16(int index) throws BufferBoundsException;
-
-    /**
-     * Get a 32-bit unsigned integer from the buffer, returning it as a long.
-     *
-     * @param index position within the data buffer to read first byte
-     * @return the unsigned 32-bit int value as a long, between 0x00000000 and 0xFFFFFFFF
-     * @throws BufferBoundsException the buffer does not contain enough bytes to service the request, or index is negative
-     */
-    long getUInt32(int index) throws BufferBoundsException;
-
-    /**
-     * Returns a signed 32-bit integer from four bytes of data at the specified index the buffer.
-     *
-     * @param index position within the data buffer to read first byte
-     * @return the signed 32 bit int value, between 0x00000000 and 0xFFFFFFFF
-     * @throws BufferBoundsException the buffer does not contain enough bytes to service the request, or index is negative
-     */
-    int getInt32(int index) throws BufferBoundsException;
-
-    /**
-     * Get a signed 64-bit integer from the buffer.
-     *
-     * @param index position within the data buffer to read first byte
-     * @return the 64 bit int value, between 0x0000000000000000 and 0xFFFFFFFFFFFFFFFF
-     * @throws BufferBoundsException the buffer does not contain enough bytes to service the request, or index is negative
-     */
-    long getInt64(int index) throws BufferBoundsException;
-
-    float getS15Fixed16(int index) throws BufferBoundsException;
-
-    float getFloat32(int index) throws BufferBoundsException;
-
-    double getDouble64(int index) throws BufferBoundsException;
-
-    @NotNull
-    byte[] getBytes(int index, int count) throws BufferBoundsException;
-
-    @NotNull
-    String getString(int index, int bytesRequested) throws BufferBoundsException;
-
-    @NotNull
-    String getString(int index, int bytesRequested, String charset) throws BufferBoundsException;
-
-    /**
-     * Creates a String from the _data buffer starting at the specified index,
-     * and ending where <code>byte=='\0'</code> or where <code>length==maxLength</code>.
-     *
-     * @param index          The index within the buffer at which to start reading the string.
-     * @param maxLengthBytes The maximum number of bytes to read.  If a zero-byte is not reached within this limit,
-     *                       reading will stop and the string will be truncated to this length.
-     * @return The read string.
-     * @throws BufferBoundsException The buffer does not contain enough bytes to satisfy this request.
-     */
-    @NotNull
-    String getNullTerminatedString(int index, int maxLengthBytes) throws BufferBoundsException;
-}
Index: trunk/src/com/drew/lang/ByteArrayReader.java
===================================================================
--- trunk/src/com/drew/lang/ByteArrayReader.java	(revision 6127)
+++ trunk/src/com/drew/lang/ByteArrayReader.java	(revision 8132)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2002-2012 Drew Noakes
+ * Copyright 2002-2015 Drew Noakes
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +16,6 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 
@@ -24,20 +24,19 @@
 import com.drew.lang.annotations.NotNull;
 
-import java.io.UnsupportedEncodingException;
+import java.io.IOException;
 
 /**
  * Provides methods to read specific values from a byte array, with a consistent, checked exception structure for
  * issues.
- * <p/>
+ * <p>
  * By default, the reader operates with Motorola byte order (big endianness).  This can be changed by calling
- * {@see setMotorolaByteOrder(boolean)}.
- * 
- * @author Drew Noakes http://drewnoakes.com
+ * <code>setMotorolaByteOrder(boolean)</code>.
+ *
+ * @author Drew Noakes https://drewnoakes.com
  * */
-public class ByteArrayReader implements BufferReader
+public class ByteArrayReader extends RandomAccessReader
 {
     @NotNull
     private final byte[] _buffer;
-    private boolean _isMotorolaByteOrder = true;
 
     @SuppressWarnings({ "ConstantConditions" })
@@ -47,5 +46,5 @@
         if (buffer == null)
             throw new NullPointerException();
-        
+
         _buffer = buffer;
     }
@@ -57,171 +56,30 @@
     }
 
-
     @Override
-    public void setMotorolaByteOrder(boolean motorolaByteOrder)
+    protected byte getByte(int index) throws IOException
     {
-        _isMotorolaByteOrder = motorolaByteOrder;
-    }
-
-    @Override
-    public boolean isMotorolaByteOrder()
-    {
-        return _isMotorolaByteOrder;
-    }
-
-    @Override
-    public short getUInt8(int index) throws BufferBoundsException
-    {
-        checkBounds(index, 1);
-
-        return (short) (_buffer[index] & 255);
-    }
-
-    @Override
-    public byte getInt8(int index) throws BufferBoundsException
-    {
-        checkBounds(index, 1);
-
         return _buffer[index];
     }
 
     @Override
-    public int getUInt16(int index) throws BufferBoundsException
+    protected void validateIndex(int index, int bytesRequested) throws IOException
     {
-        checkBounds(index, 2);
-
-        if (_isMotorolaByteOrder) {
-            // Motorola - MSB first
-            return (_buffer[index    ] << 8 & 0xFF00) |
-                   (_buffer[index + 1]      & 0xFF);
-        } else {
-            // Intel ordering - LSB first
-            return (_buffer[index + 1] << 8 & 0xFF00) |
-                   (_buffer[index    ]      & 0xFF);
-        }
+        if (!isValidIndex(index, bytesRequested))
+            throw new BufferBoundsException(index, bytesRequested, _buffer.length);
     }
 
     @Override
-    public short getInt16(int index) throws BufferBoundsException
+    protected boolean isValidIndex(int index, int bytesRequested) throws IOException
     {
-        checkBounds(index, 2);
-
-        if (_isMotorolaByteOrder) {
-            // Motorola - MSB first
-            return (short) (((short)_buffer[index    ] << 8 & (short)0xFF00) |
-                            ((short)_buffer[index + 1]      & (short)0xFF));
-        } else {
-            // Intel ordering - LSB first
-            return (short) (((short)_buffer[index + 1] << 8 & (short)0xFF00) |
-                            ((short)_buffer[index    ]      & (short)0xFF));
-        }
+        return bytesRequested >= 0
+            && index >= 0
+            && (long)index + (long)bytesRequested - 1L < (long)_buffer.length;
     }
 
     @Override
-    public long getUInt32(int index) throws BufferBoundsException
+    @NotNull
+    public byte[] getBytes(int index, int count) throws IOException
     {
-        checkBounds(index, 4);
-
-        if (_isMotorolaByteOrder) {
-            // Motorola - MSB first (big endian)
-            return (((long)_buffer[index    ]) << 24 & 0xFF000000L) |
-                    (((long)_buffer[index + 1]) << 16 & 0xFF0000L) |
-                    (((long)_buffer[index + 2]) << 8  & 0xFF00L) |
-                    (((long)_buffer[index + 3])       & 0xFFL);
-        } else {
-            // Intel ordering - LSB first (little endian)
-            return (((long)_buffer[index + 3]) << 24 & 0xFF000000L) |
-                    (((long)_buffer[index + 2]) << 16 & 0xFF0000L) |
-                    (((long)_buffer[index + 1]) << 8  & 0xFF00L) |
-                    (((long)_buffer[index    ])       & 0xFFL);
-        }
-    }
-
-    @Override
-    public int getInt32(int index) throws BufferBoundsException
-    {
-        checkBounds(index, 4);
-
-        if (_isMotorolaByteOrder) {
-            // Motorola - MSB first (big endian)
-            return (_buffer[index    ] << 24 & 0xFF000000) |
-                   (_buffer[index + 1] << 16 & 0xFF0000) |
-                   (_buffer[index + 2] << 8  & 0xFF00) |
-                   (_buffer[index + 3]       & 0xFF);
-        } else {
-            // Intel ordering - LSB first (little endian)
-            return (_buffer[index + 3] << 24 & 0xFF000000) |
-                   (_buffer[index + 2] << 16 & 0xFF0000) |
-                   (_buffer[index + 1] << 8  & 0xFF00) |
-                   (_buffer[index    ]       & 0xFF);
-        }
-    }
-
-    @Override
-    public long getInt64(int index) throws BufferBoundsException
-    {
-        checkBounds(index, 8);
-
-        if (_isMotorolaByteOrder) {
-            // Motorola - MSB first
-            return ((long)_buffer[index    ] << 56 & 0xFF00000000000000L) |
-                   ((long)_buffer[index + 1] << 48 & 0xFF000000000000L) |
-                   ((long)_buffer[index + 2] << 40 & 0xFF0000000000L) |
-                   ((long)_buffer[index + 3] << 32 & 0xFF00000000L) |
-                   ((long)_buffer[index + 4] << 24 & 0xFF000000L) |
-                   ((long)_buffer[index + 5] << 16 & 0xFF0000L) |
-                   ((long)_buffer[index + 6] << 8  & 0xFF00L) |
-                   ((long)_buffer[index + 7]       & 0xFFL);
-        } else {
-            // Intel ordering - LSB first
-            return ((long)_buffer[index + 7] << 56 & 0xFF00000000000000L) |
-                   ((long)_buffer[index + 6] << 48 & 0xFF000000000000L) |
-                   ((long)_buffer[index + 5] << 40 & 0xFF0000000000L) |
-                   ((long)_buffer[index + 4] << 32 & 0xFF00000000L) |
-                   ((long)_buffer[index + 3] << 24 & 0xFF000000L) |
-                   ((long)_buffer[index + 2] << 16 & 0xFF0000L) |
-                   ((long)_buffer[index + 1] << 8  & 0xFF00L) |
-                   ((long)_buffer[index    ]       & 0xFFL);
-        }
-    }
-
-    @Override
-    public float getS15Fixed16(int index) throws BufferBoundsException
-    {
-        checkBounds(index, 4);
-
-        if (_isMotorolaByteOrder) {
-            float res = (_buffer[index    ] & 255) << 8 |
-                        (_buffer[index + 1] & 255);
-            int d =     (_buffer[index + 2] & 255) << 8 |
-                        (_buffer[index + 3] & 255);
-            return (float)(res + d/65536.0);
-        } else {
-            // this particular branch is untested
-            float res = (_buffer[index + 3] & 255) << 8 |
-                        (_buffer[index + 2] & 255);
-            int d =     (_buffer[index + 1] & 255) << 8 |
-                        (_buffer[index    ] & 255);
-            return (float)(res + d/65536.0);
-        }
-    }
-
-    @Override
-    public float getFloat32(int index) throws BufferBoundsException
-    {
-        return Float.intBitsToFloat(getInt32(index));
-    }
-
-    @Override
-    public double getDouble64(int index) throws BufferBoundsException
-    {
-        return Double.longBitsToDouble(getInt64(index));
-    }
-    
-    @Override
-    @NotNull
-    public byte[] getBytes(int index, int count) throws BufferBoundsException
-    {
-        checkBounds(index, count);
+        validateIndex(index, count);
 
         byte[] bytes = new byte[count];
@@ -229,45 +87,3 @@
         return bytes;
     }
-
-    @Override
-    @NotNull
-    public String getString(int index, int bytesRequested) throws BufferBoundsException
-    {
-        return new String(getBytes(index, bytesRequested));
-    }
-
-    @Override
-    @NotNull
-    public String getString(int index, int bytesRequested, String charset) throws BufferBoundsException
-    {
-        byte[] bytes = getBytes(index, bytesRequested);
-        try {
-            return new String(bytes, charset);
-        } catch (UnsupportedEncodingException e) {
-            return new String(bytes);
-        }
-    }
-
-    @Override
-    @NotNull
-    public String getNullTerminatedString(int index, int maxLengthBytes) throws BufferBoundsException
-    {
-        // NOTE currently only really suited to single-byte character strings
-
-        checkBounds(index, maxLengthBytes);
-
-        // Check for null terminators
-        int length = 0;
-        while ((index + length) < _buffer.length && _buffer[index + length] != '\0' && length < maxLengthBytes)
-            length++;
-
-        byte[] bytes = getBytes(index, length);
-        return new String(bytes);
-    }
-
-    private void checkBounds(final int index, final int bytesRequested) throws BufferBoundsException
-    {
-        if (bytesRequested < 0 || index < 0 || (long)index + (long)bytesRequested - 1L >= (long)_buffer.length)
-            throw new BufferBoundsException(_buffer, index, bytesRequested);
-    }
 }
Index: trunk/src/com/drew/lang/CompoundException.java
===================================================================
--- trunk/src/com/drew/lang/CompoundException.java	(revision 6127)
+++ trunk/src/com/drew/lang/CompoundException.java	(revision 8132)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2002-2012 Drew Noakes
+ * Copyright 2002-2015 Drew Noakes
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +16,6 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 package com.drew.lang;
@@ -32,5 +32,5 @@
  * of these previous JDK versions.
  *
- * @author Drew Noakes http://drewnoakes.com
+ * @author Drew Noakes https://drewnoakes.com
  */
 public class CompoundException extends Exception
@@ -63,4 +63,5 @@
     }
 
+    @Override
     @NotNull
     public String toString()
@@ -77,4 +78,5 @@
     }
 
+    @Override
     public void printStackTrace(@NotNull PrintStream s)
     {
@@ -86,4 +88,5 @@
     }
 
+    @Override
     public void printStackTrace(@NotNull PrintWriter s)
     {
@@ -95,4 +98,5 @@
     }
 
+    @Override
     public void printStackTrace()
     {
Index: trunk/src/com/drew/lang/GeoLocation.java
===================================================================
--- trunk/src/com/drew/lang/GeoLocation.java	(revision 6127)
+++ trunk/src/com/drew/lang/GeoLocation.java	(revision 8132)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2002-2012 Drew Noakes
+ * Copyright 2002-2015 Drew Noakes
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +16,6 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 
@@ -25,7 +25,11 @@
 import com.drew.lang.annotations.Nullable;
 
+import java.text.DecimalFormat;
+
 /**
  * Represents a latitude and longitude pair, giving a position on earth in spherical coordinates.
+ * <p>
  * Values of latitude and longitude are given in degrees.
+ * <p>
  * This type is immutable.
  */
@@ -79,5 +83,6 @@
     {
         double[] dms = decimalToDegreesMinutesSeconds(decimal);
-        return dms[0] + "° " + dms[1] + "' " + dms[2] + '"';
+        DecimalFormat format = new DecimalFormat("0.##");
+        return String.format("%s° %s' %s\"", format.format(dms[0]), format.format(dms[1]), format.format(dms[2]));
     }
 
Index: trunk/src/com/drew/lang/NullOutputStream.java
===================================================================
--- trunk/src/com/drew/lang/NullOutputStream.java	(revision 6127)
+++ trunk/src/com/drew/lang/NullOutputStream.java	(revision 8132)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2002-2012 Drew Noakes
+ * Copyright 2002-2015 Drew Noakes
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +16,6 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 package com.drew.lang;
@@ -27,5 +27,5 @@
  * An implementation of OutputSteam that ignores write requests by doing nothing.  This class may be useful in tests.
  *
- * @author Drew Noakes http://drewnoakes.com
+ * @author Drew Noakes https://drewnoakes.com
  */
 public class NullOutputStream extends OutputStream
@@ -36,4 +36,5 @@
     }
 
+    @Override
     public void write(int b) throws IOException
     {
Index: trunk/src/com/drew/lang/RandomAccessReader.java
===================================================================
--- trunk/src/com/drew/lang/RandomAccessReader.java	(revision 8132)
+++ trunk/src/com/drew/lang/RandomAccessReader.java	(revision 8132)
@@ -0,0 +1,365 @@
+/*
+ * Copyright 2002-2015 Drew Noakes
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ *
+ * More information about this project is available at:
+ *
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
+ */
+
+package com.drew.lang;
+
+import com.drew.lang.annotations.NotNull;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Base class for random access data reading operations of common data types.
+ * <p>
+ * By default, the reader operates with Motorola byte order (big endianness).  This can be changed by calling
+ * {@link com.drew.lang.RandomAccessReader#setMotorolaByteOrder(boolean)}.
+ * <p>
+ * Concrete implementations include:
+ * <ul>
+ *     <li>{@link ByteArrayReader}</li>
+ *     <li>{@link RandomAccessStreamReader}</li>
+ * </ul>
+ *
+ * @author Drew Noakes https://drewnoakes.com
+ */
+public abstract class RandomAccessReader
+{
+    private boolean _isMotorolaByteOrder = true;
+
+    /**
+     * Gets the byte value at the specified byte <code>index</code>.
+     * <p>
+     * Implementations should not perform any bounds checking in this method. That should be performed
+     * in <code>validateIndex</code> and <code>isValidIndex</code>.
+     *
+     * @param index The index from which to read the byte
+     * @return The read byte value
+     * @throws IllegalArgumentException <code>index</code> or <code>count</code> are negative
+     * @throws BufferBoundsException if the requested byte is beyond the end of the underlying data source
+     * @throws IOException if the byte is unable to be read
+     */
+    protected abstract byte getByte(int index) throws IOException;
+
+    /**
+     * Returns the required number of bytes from the specified index from the underlying source.
+     *
+     * @param index The index from which the bytes begins in the underlying source
+     * @param count The number of bytes to be returned
+     * @return The requested bytes
+     * @throws IllegalArgumentException <code>index</code> or <code>count</code> are negative
+     * @throws BufferBoundsException if the requested bytes extend beyond the end of the underlying data source
+     * @throws IOException if the byte is unable to be read
+     */
+    @NotNull
+    public abstract byte[] getBytes(int index, int count) throws IOException;
+
+    /**
+     * Ensures that the buffered bytes extend to cover the specified index. If not, an attempt is made
+     * to read to that point.
+     * <p>
+     * If the stream ends before the point is reached, a {@link BufferBoundsException} is raised.
+     *
+     * @param index the index from which the required bytes start
+     * @param bytesRequested the number of bytes which are required
+     * @throws IOException if the stream ends before the required number of bytes are acquired
+     */
+    protected abstract void validateIndex(int index, int bytesRequested) throws IOException;
+
+    protected abstract boolean isValidIndex(int index, int bytesRequested) throws IOException;
+
+    /**
+     * Returns the length of the data source in bytes.
+     * <p>
+     * This is a simple operation for implementations (such as {@link RandomAccessFileReader} and
+     * {@link ByteArrayReader}) that have the entire data source available.
+     * <p>
+     * Users of this method must be aware that sequentially accessed implementations such as
+     * {@link RandomAccessStreamReader} will have to read and buffer the entire data source in
+     * order to determine the length.
+     *
+     * @return the length of the data source, in bytes.
+     */
+    public abstract long getLength() throws IOException;
+
+    /**
+     * Sets the endianness of this reader.
+     * <ul>
+     * <li><code>true</code> for Motorola (or big) endianness (also known as network byte order), with MSB before LSB.</li>
+     * <li><code>false</code> for Intel (or little) endianness, with LSB before MSB.</li>
+     * </ul>
+     *
+     * @param motorolaByteOrder <code>true</code> for Motorola/big endian, <code>false</code> for Intel/little endian
+     */
+    public void setMotorolaByteOrder(boolean motorolaByteOrder)
+    {
+        _isMotorolaByteOrder = motorolaByteOrder;
+    }
+
+    /**
+     * Gets the endianness of this reader.
+     * <ul>
+     * <li><code>true</code> for Motorola (or big) endianness (also known as network byte order), with MSB before LSB.</li>
+     * <li><code>false</code> for Intel (or little) endianness, with LSB before MSB.</li>
+     * </ul>
+     */
+    public boolean isMotorolaByteOrder()
+    {
+        return _isMotorolaByteOrder;
+    }
+
+    /**
+     * Returns an unsigned 8-bit int calculated from one byte of data at the specified index.
+     *
+     * @param index position within the data buffer to read byte
+     * @return the 8 bit int value, between 0 and 255
+     * @throws IOException the buffer does not contain enough bytes to service the request, or index is negative
+     */
+    public short getUInt8(int index) throws IOException
+    {
+        validateIndex(index, 1);
+
+        return (short) (getByte(index) & 0xFF);
+    }
+
+    /**
+     * Returns a signed 8-bit int calculated from one byte of data at the specified index.
+     *
+     * @param index position within the data buffer to read byte
+     * @return the 8 bit int value, between 0x00 and 0xFF
+     * @throws IOException the buffer does not contain enough bytes to service the request, or index is negative
+     */
+    public byte getInt8(int index) throws IOException
+    {
+        validateIndex(index, 1);
+
+        return getByte(index);
+    }
+
+    /**
+     * Returns an unsigned 16-bit int calculated from two bytes of data at the specified index.
+     *
+     * @param index position within the data buffer to read first byte
+     * @return the 16 bit int value, between 0x0000 and 0xFFFF
+     * @throws IOException the buffer does not contain enough bytes to service the request, or index is negative
+     */
+    public int getUInt16(int index) throws IOException
+    {
+        validateIndex(index, 2);
+
+        if (_isMotorolaByteOrder) {
+            // Motorola - MSB first
+            return (getByte(index    ) << 8 & 0xFF00) |
+                   (getByte(index + 1)      & 0xFF);
+        } else {
+            // Intel ordering - LSB first
+            return (getByte(index + 1) << 8 & 0xFF00) |
+                   (getByte(index    )      & 0xFF);
+        }
+    }
+
+    /**
+     * Returns a signed 16-bit int calculated from two bytes of data at the specified index (MSB, LSB).
+     *
+     * @param index position within the data buffer to read first byte
+     * @return the 16 bit int value, between 0x0000 and 0xFFFF
+     * @throws IOException the buffer does not contain enough bytes to service the request, or index is negative
+     */
+    public short getInt16(int index) throws IOException
+    {
+        validateIndex(index, 2);
+
+        if (_isMotorolaByteOrder) {
+            // Motorola - MSB first
+            return (short) (((short)getByte(index    ) << 8 & (short)0xFF00) |
+                            ((short)getByte(index + 1)      & (short)0xFF));
+        } else {
+            // Intel ordering - LSB first
+            return (short) (((short)getByte(index + 1) << 8 & (short)0xFF00) |
+                            ((short)getByte(index    )      & (short)0xFF));
+        }
+    }
+
+    /**
+     * Get a 32-bit unsigned integer from the buffer, returning it as a long.
+     *
+     * @param index position within the data buffer to read first byte
+     * @return the unsigned 32-bit int value as a long, between 0x00000000 and 0xFFFFFFFF
+     * @throws IOException the buffer does not contain enough bytes to service the request, or index is negative
+     */
+    public long getUInt32(int index) throws IOException
+    {
+        validateIndex(index, 4);
+
+        if (_isMotorolaByteOrder) {
+            // Motorola - MSB first (big endian)
+            return (((long)getByte(index    )) << 24 & 0xFF000000L) |
+                   (((long)getByte(index + 1)) << 16 & 0xFF0000L) |
+                   (((long)getByte(index + 2)) << 8  & 0xFF00L) |
+                   (((long)getByte(index + 3))       & 0xFFL);
+        } else {
+            // Intel ordering - LSB first (little endian)
+            return (((long)getByte(index + 3)) << 24 & 0xFF000000L) |
+                   (((long)getByte(index + 2)) << 16 & 0xFF0000L) |
+                   (((long)getByte(index + 1)) << 8  & 0xFF00L) |
+                   (((long)getByte(index    ))       & 0xFFL);
+        }
+    }
+
+    /**
+     * Returns a signed 32-bit integer from four bytes of data at the specified index the buffer.
+     *
+     * @param index position within the data buffer to read first byte
+     * @return the signed 32 bit int value, between 0x00000000 and 0xFFFFFFFF
+     * @throws IOException the buffer does not contain enough bytes to service the request, or index is negative
+     */
+    public int getInt32(int index) throws IOException
+    {
+        validateIndex(index, 4);
+
+        if (_isMotorolaByteOrder) {
+            // Motorola - MSB first (big endian)
+            return (getByte(index    ) << 24 & 0xFF000000) |
+                   (getByte(index + 1) << 16 & 0xFF0000) |
+                   (getByte(index + 2) << 8  & 0xFF00) |
+                   (getByte(index + 3)       & 0xFF);
+        } else {
+            // Intel ordering - LSB first (little endian)
+            return (getByte(index + 3) << 24 & 0xFF000000) |
+                   (getByte(index + 2) << 16 & 0xFF0000) |
+                   (getByte(index + 1) << 8  & 0xFF00) |
+                   (getByte(index    )       & 0xFF);
+        }
+    }
+
+    /**
+     * Get a signed 64-bit integer from the buffer.
+     *
+     * @param index position within the data buffer to read first byte
+     * @return the 64 bit int value, between 0x0000000000000000 and 0xFFFFFFFFFFFFFFFF
+     * @throws IOException the buffer does not contain enough bytes to service the request, or index is negative
+     */
+    public long getInt64(int index) throws IOException
+    {
+        validateIndex(index, 8);
+
+        if (_isMotorolaByteOrder) {
+            // Motorola - MSB first
+            return ((long)getByte(index    ) << 56 & 0xFF00000000000000L) |
+                   ((long)getByte(index + 1) << 48 & 0xFF000000000000L) |
+                   ((long)getByte(index + 2) << 40 & 0xFF0000000000L) |
+                   ((long)getByte(index + 3) << 32 & 0xFF00000000L) |
+                   ((long)getByte(index + 4) << 24 & 0xFF000000L) |
+                   ((long)getByte(index + 5) << 16 & 0xFF0000L) |
+                   ((long)getByte(index + 6) << 8  & 0xFF00L) |
+                   ((long)getByte(index + 7)       & 0xFFL);
+        } else {
+            // Intel ordering - LSB first
+            return ((long)getByte(index + 7) << 56 & 0xFF00000000000000L) |
+                   ((long)getByte(index + 6) << 48 & 0xFF000000000000L) |
+                   ((long)getByte(index + 5) << 40 & 0xFF0000000000L) |
+                   ((long)getByte(index + 4) << 32 & 0xFF00000000L) |
+                   ((long)getByte(index + 3) << 24 & 0xFF000000L) |
+                   ((long)getByte(index + 2) << 16 & 0xFF0000L) |
+                   ((long)getByte(index + 1) << 8  & 0xFF00L) |
+                   ((long)getByte(index    )       & 0xFFL);
+        }
+    }
+
+    /**
+     * Gets a s15.16 fixed point float from the buffer.
+     * <p>
+     * This particular fixed point encoding has one sign bit, 15 numerator bits and 16 denominator bits.
+     *
+     * @return the floating point value
+     * @throws IOException the buffer does not contain enough bytes to service the request, or index is negative
+     */
+    public float getS15Fixed16(int index) throws IOException
+    {
+        validateIndex(index, 4);
+
+        if (_isMotorolaByteOrder) {
+            float res = (getByte(index    ) & 0xFF) << 8 |
+                        (getByte(index + 1) & 0xFF);
+            int d =     (getByte(index + 2) & 0xFF) << 8 |
+                        (getByte(index + 3) & 0xFF);
+            return (float)(res + d/65536.0);
+        } else {
+            // this particular branch is untested
+            float res = (getByte(index + 3) & 0xFF) << 8 |
+                        (getByte(index + 2) & 0xFF);
+            int d =     (getByte(index + 1) & 0xFF) << 8 |
+                        (getByte(index    ) & 0xFF);
+            return (float)(res + d/65536.0);
+        }
+    }
+
+    public float getFloat32(int index) throws IOException
+    {
+        return Float.intBitsToFloat(getInt32(index));
+    }
+
+    public double getDouble64(int index) throws IOException
+    {
+        return Double.longBitsToDouble(getInt64(index));
+    }
+
+    @NotNull
+    public String getString(int index, int bytesRequested) throws IOException
+    {
+        return new String(getBytes(index, bytesRequested));
+    }
+
+    @NotNull
+    public String getString(int index, int bytesRequested, String charset) throws IOException
+    {
+        byte[] bytes = getBytes(index, bytesRequested);
+        try {
+            return new String(bytes, charset);
+        } catch (UnsupportedEncodingException e) {
+            return new String(bytes);
+        }
+    }
+
+    /**
+     * Creates a String from the _data buffer starting at the specified index,
+     * and ending where <code>byte=='\0'</code> or where <code>length==maxLength</code>.
+     *
+     * @param index          The index within the buffer at which to start reading the string.
+     * @param maxLengthBytes The maximum number of bytes to read.  If a zero-byte is not reached within this limit,
+     *                       reading will stop and the string will be truncated to this length.
+     * @return The read string.
+     * @throws IOException The buffer does not contain enough bytes to satisfy this request.
+     */
+    @NotNull
+    public String getNullTerminatedString(int index, int maxLengthBytes) throws IOException
+    {
+        // NOTE currently only really suited to single-byte character strings
+
+        byte[] bytes = getBytes(index, maxLengthBytes);
+
+        // Count the number of non-null bytes
+        int length = 0;
+        while (length < bytes.length && bytes[length] != '\0')
+            length++;
+
+        return new String(bytes, 0, length);
+    }
+}
Index: trunk/src/com/drew/lang/Rational.java
===================================================================
--- trunk/src/com/drew/lang/Rational.java	(revision 6127)
+++ trunk/src/com/drew/lang/Rational.java	(revision 8132)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2002-2012 Drew Noakes
+ * Copyright 2002-2015 Drew Noakes
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +16,6 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 
@@ -29,7 +29,10 @@
 /**
  * Immutable class for holding a rational number without loss of precision.  Provides
- * a familiar representation via toString() in form <code>numerator/denominator</code>.
- *
- * @author Drew Noakes http://drewnoakes.com
+ * a familiar representation via {@link Rational#toString} in form <code>numerator/denominator</code>.
+ *
+ * Note that any value with a numerator of zero will be treated as zero, even if the
+ * denominator is also zero.
+ *
+ * @author Drew Noakes https://drewnoakes.com
  */
 public class Rational extends java.lang.Number implements Serializable
@@ -61,7 +64,10 @@
      *         to type <code>double</code>.
      */
+    @Override
     public double doubleValue()
     {
-        return (double) _numerator / (double) _denominator;
+        return _numerator == 0
+            ? 0.0
+            : (double) _numerator / (double) _denominator;
     }
 
@@ -73,7 +79,10 @@
      *         to type <code>float</code>.
      */
+    @Override
     public float floatValue()
     {
-        return (float) _numerator / (float) _denominator;
+        return _numerator == 0
+            ? 0.0f
+            : (float) _numerator / (float) _denominator;
     }
 
@@ -81,9 +90,10 @@
      * Returns the value of the specified number as a <code>byte</code>.
      * This may involve rounding or truncation.  This implementation simply
-     * casts the result of <code>doubleValue()</code> to <code>byte</code>.
+     * casts the result of {@link Rational#doubleValue} to <code>byte</code>.
      *
      * @return the numeric value represented by this object after conversion
      *         to type <code>byte</code>.
      */
+    @Override
     public final byte byteValue()
     {
@@ -94,9 +104,10 @@
      * Returns the value of the specified number as an <code>int</code>.
      * This may involve rounding or truncation.  This implementation simply
-     * casts the result of <code>doubleValue()</code> to <code>int</code>.
+     * casts the result of {@link Rational#doubleValue} to <code>int</code>.
      *
      * @return the numeric value represented by this object after conversion
      *         to type <code>int</code>.
      */
+    @Override
     public final int intValue()
     {
@@ -107,9 +118,10 @@
      * Returns the value of the specified number as a <code>long</code>.
      * This may involve rounding or truncation.  This implementation simply
-     * casts the result of <code>doubleValue()</code> to <code>long</code>.
+     * casts the result of {@link Rational#doubleValue} to <code>long</code>.
      *
      * @return the numeric value represented by this object after conversion
      *         to type <code>long</code>.
      */
+    @Override
     public final long longValue()
     {
@@ -120,9 +132,10 @@
      * Returns the value of the specified number as a <code>short</code>.
      * This may involve rounding or truncation.  This implementation simply
-     * casts the result of <code>doubleValue()</code> to <code>short</code>.
+     * casts the result of {@link Rational#doubleValue} to <code>short</code>.
      *
      * @return the numeric value represented by this object after conversion
      *         to type <code>short</code>.
      */
+    @Override
     public final short shortValue()
     {
@@ -154,5 +167,5 @@
     }
 
-    /** Checks if this rational number is an Integer, either positive or negative. */
+    /** Checks if this {@link Rational} number is an Integer, either positive or negative. */
     public boolean isInteger()
     {
@@ -167,4 +180,5 @@
      * @return a string representation of the object.
      */
+    @Override
     @NotNull
     public String toString()
@@ -173,5 +187,5 @@
     }
 
-    /** Returns the simplest representation of this Rational's value possible. */
+    /** Returns the simplest representation of this {@link Rational}'s value possible. */
     @NotNull
     public String toSimpleString(boolean allowDecimal)
@@ -211,10 +225,10 @@
 
     /**
-     * Compares two <code>Rational</code> instances, returning true if they are mathematically
+     * Compares two {@link Rational} instances, returning true if they are mathematically
      * equivalent.
      *
-     * @param obj the Rational to compare this instance to.
+     * @param obj the {@link Rational} to compare this instance to.
      * @return true if instances are mathematically equivalent, otherwise false.  Will also
-     *         return false if <code>obj</code> is not an instance of <code>Rational</code>.
+     *         return false if <code>obj</code> is not an instance of {@link Rational}.
      */
     @Override
@@ -235,5 +249,5 @@
     /**
      * <p>
-     * Simplifies the Rational number.</p>
+     * Simplifies the {@link Rational} number.</p>
      * <p>
      * Prime number series: 1, 2, 3, 5, 7, 9, 11, 13, 17</p>
@@ -244,5 +258,5 @@
      * <p>
      * However, generating the prime number series seems to be a hefty task.  Perhaps
-     * it's simpler to check if both d & n are divisible by all numbers from 2 ->
+     * it's simpler to check if both d &amp; n are divisible by all numbers from 2 {@literal ->}
      * (Math.min(denominator, numerator) / 2).  In doing this, one can check for 2
      * and 5 once, then ignore all even numbers, and all numbers ending in 0 or 5.
@@ -250,13 +264,13 @@
      * <p>
      * Therefore, the max number of pairs of modulus divisions required will be:</p>
-     * <code><pre>
+     * <pre><code>
      *    4   Math.min(denominator, numerator) - 1
      *   -- * ------------------------------------ + 2
      *   10                    2
-     * <p/>
+     *
      *   Math.min(denominator, numerator) - 1
      * = ------------------------------------ + 2
      *                  5
-     * </pre></code>
+     * </code></pre>
      *
      * @return a simplified instance, or if the Rational could not be simplified,
Index: trunk/src/com/drew/lang/SequentialByteArrayReader.java
===================================================================
--- trunk/src/com/drew/lang/SequentialByteArrayReader.java	(revision 8132)
+++ trunk/src/com/drew/lang/SequentialByteArrayReader.java	(revision 8132)
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2002-2015 Drew Noakes
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ *
+ * More information about this project is available at:
+ *
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
+ */
+
+package com.drew.lang;
+
+import com.drew.lang.annotations.NotNull;
+
+import java.io.EOFException;
+import java.io.IOException;
+
+/**
+ *
+ * @author Drew Noakes https://drewnoakes.com
+ */
+public class SequentialByteArrayReader extends SequentialReader
+{
+    @NotNull
+    private final byte[] _bytes;
+    private int _index;
+
+    @SuppressWarnings("ConstantConditions")
+    public SequentialByteArrayReader(@NotNull byte[] bytes)
+    {
+        if (bytes == null)
+            throw new NullPointerException();
+
+        _bytes = bytes;
+        _index = 0;
+    }
+
+    @Override
+    protected byte getByte() throws IOException
+    {
+        if (_index >= _bytes.length) {
+            throw new EOFException("End of data reached.");
+        }
+        return _bytes[_index++];
+    }
+
+    @NotNull
+    @Override
+    public byte[] getBytes(int count) throws IOException
+    {
+        if (_index + count > _bytes.length) {
+            throw new EOFException("End of data reached.");
+        }
+
+        byte[] bytes = new byte[count];
+        System.arraycopy(_bytes, _index, bytes, 0, count);
+        _index += count;
+
+        return bytes;
+    }
+
+    @Override
+    public void skip(long n) throws IOException
+    {
+        if (n < 0) {
+            throw new IllegalArgumentException("n must be zero or greater.");
+        }
+
+        if (_index + n > _bytes.length) {
+            throw new EOFException("End of data reached.");
+        }
+
+        _index += n;
+    }
+
+    @Override
+    public boolean trySkip(long n) throws IOException
+    {
+        if (n < 0) {
+            throw new IllegalArgumentException("n must be zero or greater.");
+        }
+
+        _index += n;
+
+        if (_index > _bytes.length) {
+            _index = _bytes.length;
+            return false;
+        }
+
+        return true;
+    }
+}
Index: trunk/src/com/drew/lang/SequentialReader.java
===================================================================
--- trunk/src/com/drew/lang/SequentialReader.java	(revision 8132)
+++ trunk/src/com/drew/lang/SequentialReader.java	(revision 8132)
@@ -0,0 +1,308 @@
+/*
+ * Copyright 2002-2015 Drew Noakes
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ *
+ * More information about this project is available at:
+ *
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
+ */
+
+package com.drew.lang;
+
+import com.drew.lang.annotations.NotNull;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * @author Drew Noakes https://drewnoakes.com
+ */
+public abstract class SequentialReader
+{
+    // TODO review whether the masks are needed (in both this and RandomAccessReader)
+
+    private boolean _isMotorolaByteOrder = true;
+
+    /**
+     * Gets the next byte in the sequence.
+     *
+     * @return The read byte value
+     */
+    protected abstract byte getByte() throws IOException;
+
+    /**
+     * Returns the required number of bytes from the sequence.
+     *
+     * @param count The number of bytes to be returned
+     * @return The requested bytes
+     */
+    @NotNull
+    public abstract byte[] getBytes(int count) throws IOException;
+
+    /**
+     * Skips forward in the sequence. If the sequence ends, an {@link EOFException} is thrown.
+     *
+     * @param n the number of byte to skip. Must be zero or greater.
+     * @throws EOFException the end of the sequence is reached.
+     * @throws IOException an error occurred reading from the underlying source.
+     */
+    public abstract void skip(long n) throws IOException;
+
+    /**
+     * Skips forward in the sequence, returning a boolean indicating whether the skip succeeded, or whether the sequence ended.
+     *
+     * @param n the number of byte to skip. Must be zero or greater.
+     * @return a boolean indicating whether the skip succeeded, or whether the sequence ended.
+     * @throws IOException an error occurred reading from the underlying source.
+     */
+    public abstract boolean trySkip(long n) throws IOException;
+
+    /**
+     * Sets the endianness of this reader.
+     * <ul>
+     * <li><code>true</code> for Motorola (or big) endianness (also known as network byte order), with MSB before LSB.</li>
+     * <li><code>false</code> for Intel (or little) endianness, with LSB before MSB.</li>
+     * </ul>
+     *
+     * @param motorolaByteOrder <code>true</code> for Motorola/big endian, <code>false</code> for Intel/little endian
+     */
+    public void setMotorolaByteOrder(boolean motorolaByteOrder)
+    {
+        _isMotorolaByteOrder = motorolaByteOrder;
+    }
+
+    /**
+     * Gets the endianness of this reader.
+     * <ul>
+     * <li><code>true</code> for Motorola (or big) endianness (also known as network byte order), with MSB before LSB.</li>
+     * <li><code>false</code> for Intel (or little) endianness, with LSB before MSB.</li>
+     * </ul>
+     */
+    public boolean isMotorolaByteOrder()
+    {
+        return _isMotorolaByteOrder;
+    }
+
+    /**
+     * Returns an unsigned 8-bit int calculated from the next byte of the sequence.
+     *
+     * @return the 8 bit int value, between 0 and 255
+     */
+    public short getUInt8() throws IOException
+    {
+        return (short) (getByte() & 0xFF);
+    }
+
+    /**
+     * Returns a signed 8-bit int calculated from the next byte the sequence.
+     *
+     * @return the 8 bit int value, between 0x00 and 0xFF
+     */
+    public byte getInt8() throws IOException
+    {
+        return getByte();
+    }
+
+    /**
+     * Returns an unsigned 16-bit int calculated from the next two bytes of the sequence.
+     *
+     * @return the 16 bit int value, between 0x0000 and 0xFFFF
+     */
+    public int getUInt16() throws IOException
+    {
+        if (_isMotorolaByteOrder) {
+            // Motorola - MSB first
+            return (getByte() << 8 & 0xFF00) |
+                   (getByte()      & 0xFF);
+        } else {
+            // Intel ordering - LSB first
+            return (getByte()      & 0xFF) |
+                   (getByte() << 8 & 0xFF00);
+        }
+    }
+
+    /**
+     * Returns a signed 16-bit int calculated from two bytes of data (MSB, LSB).
+     *
+     * @return the 16 bit int value, between 0x0000 and 0xFFFF
+     * @throws IOException the buffer does not contain enough bytes to service the request
+     */
+    public short getInt16() throws IOException
+    {
+        if (_isMotorolaByteOrder) {
+            // Motorola - MSB first
+            return (short) (((short)getByte() << 8 & (short)0xFF00) |
+                            ((short)getByte()      & (short)0xFF));
+        } else {
+            // Intel ordering - LSB first
+            return (short) (((short)getByte()      & (short)0xFF) |
+                            ((short)getByte() << 8 & (short)0xFF00));
+        }
+    }
+
+    /**
+     * Get a 32-bit unsigned integer from the buffer, returning it as a long.
+     *
+     * @return the unsigned 32-bit int value as a long, between 0x00000000 and 0xFFFFFFFF
+     * @throws IOException the buffer does not contain enough bytes to service the request
+     */
+    public long getUInt32() throws IOException
+    {
+        if (_isMotorolaByteOrder) {
+            // Motorola - MSB first (big endian)
+            return (((long)getByte()) << 24 & 0xFF000000L) |
+                   (((long)getByte()) << 16 & 0xFF0000L) |
+                   (((long)getByte()) << 8  & 0xFF00L) |
+                   (((long)getByte())       & 0xFFL);
+        } else {
+            // Intel ordering - LSB first (little endian)
+            return (((long)getByte())       & 0xFFL) |
+                   (((long)getByte()) << 8  & 0xFF00L) |
+                   (((long)getByte()) << 16 & 0xFF0000L) |
+                   (((long)getByte()) << 24 & 0xFF000000L);
+        }
+    }
+
+    /**
+     * Returns a signed 32-bit integer from four bytes of data.
+     *
+     * @return the signed 32 bit int value, between 0x00000000 and 0xFFFFFFFF
+     * @throws IOException the buffer does not contain enough bytes to service the request
+     */
+    public int getInt32() throws IOException
+    {
+        if (_isMotorolaByteOrder) {
+            // Motorola - MSB first (big endian)
+            return (getByte() << 24 & 0xFF000000) |
+                   (getByte() << 16 & 0xFF0000) |
+                   (getByte() << 8  & 0xFF00) |
+                   (getByte()       & 0xFF);
+        } else {
+            // Intel ordering - LSB first (little endian)
+            return (getByte()       & 0xFF) |
+                   (getByte() << 8  & 0xFF00) |
+                   (getByte() << 16 & 0xFF0000) |
+                   (getByte() << 24 & 0xFF000000);
+        }
+    }
+
+    /**
+     * Get a signed 64-bit integer from the buffer.
+     *
+     * @return the 64 bit int value, between 0x0000000000000000 and 0xFFFFFFFFFFFFFFFF
+     * @throws IOException the buffer does not contain enough bytes to service the request
+     */
+    public long getInt64() throws IOException
+    {
+        if (_isMotorolaByteOrder) {
+            // Motorola - MSB first
+            return ((long)getByte() << 56 & 0xFF00000000000000L) |
+                   ((long)getByte() << 48 & 0xFF000000000000L) |
+                   ((long)getByte() << 40 & 0xFF0000000000L) |
+                   ((long)getByte() << 32 & 0xFF00000000L) |
+                   ((long)getByte() << 24 & 0xFF000000L) |
+                   ((long)getByte() << 16 & 0xFF0000L) |
+                   ((long)getByte() << 8  & 0xFF00L) |
+                   ((long)getByte()       & 0xFFL);
+        } else {
+            // Intel ordering - LSB first
+            return ((long)getByte()       & 0xFFL) |
+                   ((long)getByte() << 8  & 0xFF00L) |
+                   ((long)getByte() << 16 & 0xFF0000L) |
+                   ((long)getByte() << 24 & 0xFF000000L) |
+                   ((long)getByte() << 32 & 0xFF00000000L) |
+                   ((long)getByte() << 40 & 0xFF0000000000L) |
+                   ((long)getByte() << 48 & 0xFF000000000000L) |
+                   ((long)getByte() << 56 & 0xFF00000000000000L);
+        }
+    }
+
+    /**
+     * Gets a s15.16 fixed point float from the buffer.
+     * <p>
+     * This particular fixed point encoding has one sign bit, 15 numerator bits and 16 denominator bits.
+     *
+     * @return the floating point value
+     * @throws IOException the buffer does not contain enough bytes to service the request
+     */
+    public float getS15Fixed16() throws IOException
+    {
+        if (_isMotorolaByteOrder) {
+            float res = (getByte() & 0xFF) << 8 |
+                        (getByte() & 0xFF);
+            int d =     (getByte() & 0xFF) << 8 |
+                        (getByte() & 0xFF);
+            return (float)(res + d/65536.0);
+        } else {
+            // this particular branch is untested
+            int d =     (getByte() & 0xFF) |
+                        (getByte() & 0xFF) << 8;
+            float res = (getByte() & 0xFF) |
+                        (getByte() & 0xFF) << 8;
+            return (float)(res + d/65536.0);
+        }
+    }
+
+    public float getFloat32() throws IOException
+    {
+        return Float.intBitsToFloat(getInt32());
+    }
+
+    public double getDouble64() throws IOException
+    {
+        return Double.longBitsToDouble(getInt64());
+    }
+
+    @NotNull
+    public String getString(int bytesRequested) throws IOException
+    {
+        return new String(getBytes(bytesRequested));
+    }
+
+    @NotNull
+    public String getString(int bytesRequested, String charset) throws IOException
+    {
+        byte[] bytes = getBytes(bytesRequested);
+        try {
+            return new String(bytes, charset);
+        } catch (UnsupportedEncodingException e) {
+            return new String(bytes);
+        }
+    }
+
+    /**
+     * Creates a String from the stream, ending where <code>byte=='\0'</code> or where <code>length==maxLength</code>.
+     *
+     * @param maxLengthBytes The maximum number of bytes to read.  If a zero-byte is not reached within this limit,
+     *                       reading will stop and the string will be truncated to this length.
+     * @return The read string.
+     * @throws IOException The buffer does not contain enough bytes to satisfy this request.
+     */
+    @NotNull
+    public String getNullTerminatedString(int maxLengthBytes) throws IOException
+    {
+        // NOTE currently only really suited to single-byte character strings
+
+        byte[] bytes = new byte[maxLengthBytes];
+
+        // Count the number of non-null bytes
+        int length = 0;
+        while (length < bytes.length && (bytes[length] = getByte()) != '\0')
+            length++;
+
+        return new String(bytes, 0, length);
+    }
+}
Index: trunk/src/com/drew/lang/StreamReader.java
===================================================================
--- trunk/src/com/drew/lang/StreamReader.java	(revision 8132)
+++ trunk/src/com/drew/lang/StreamReader.java	(revision 8132)
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2002-2015 Drew Noakes
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ *
+ * More information about this project is available at:
+ *
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
+ */
+
+package com.drew.lang;
+
+import com.drew.lang.annotations.NotNull;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ *
+ * @author Drew Noakes https://drewnoakes.com
+ */
+public class StreamReader extends SequentialReader
+{
+    @NotNull
+    private final InputStream _stream;
+
+    @SuppressWarnings("ConstantConditions")
+    public StreamReader(@NotNull InputStream stream)
+    {
+        if (stream == null)
+            throw new NullPointerException();
+
+        _stream = stream;
+    }
+
+    @Override
+    protected byte getByte() throws IOException
+    {
+        int value = _stream.read();
+        if (value == -1)
+            throw new EOFException("End of data reached.");
+        return (byte)value;
+    }
+
+    @NotNull
+    @Override
+    public byte[] getBytes(int count) throws IOException
+    {
+        byte[] bytes = new byte[count];
+        int totalBytesRead = 0;
+
+        while (totalBytesRead != count) {
+            final int bytesRead = _stream.read(bytes, totalBytesRead, count - totalBytesRead);
+            if (bytesRead == -1)
+                throw new EOFException("End of data reached.");
+            totalBytesRead += bytesRead;
+            assert(totalBytesRead <= count);
+        }
+
+        return bytes;
+    }
+
+    @Override
+    public void skip(long n) throws IOException
+    {
+        if (n < 0)
+            throw new IllegalArgumentException("n must be zero or greater.");
+
+        long skippedCount = skipInternal(n);
+
+        if (skippedCount != n)
+            throw new EOFException(String.format("Unable to skip. Requested %d bytes but skipped %d.", n, skippedCount));
+    }
+
+    @Override
+    public boolean trySkip(long n) throws IOException
+    {
+        if (n < 0)
+            throw new IllegalArgumentException("n must be zero or greater.");
+
+        return skipInternal(n) == n;
+    }
+
+    private long skipInternal(long n) throws IOException
+    {
+        // It seems that for some streams, such as BufferedInputStream, that skip can return
+        // some smaller number than was requested. So loop until we either skip enough, or
+        // InputStream.skip returns zero.
+        //
+        // See http://stackoverflow.com/questions/14057720/robust-skipping-of-data-in-a-java-io-inputstream-and-its-subtypes
+        //
+        long skippedTotal = 0;
+        while (skippedTotal != n) {
+            long skipped = _stream.skip(n - skippedTotal);
+            assert(skipped >= 0);
+            skippedTotal += skipped;
+            if (skipped == 0)
+                break;
+        }
+        return skippedTotal;
+    }
+}
Index: trunk/src/com/drew/lang/StringUtil.java
===================================================================
--- trunk/src/com/drew/lang/StringUtil.java	(revision 6127)
+++ trunk/src/com/drew/lang/StringUtil.java	(revision 8132)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2002-2012 Drew Noakes
+ * Copyright 2002-2015 Drew Noakes
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +16,6 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 
@@ -23,10 +23,18 @@
 
 import com.drew.lang.annotations.NotNull;
+import com.drew.lang.annotations.Nullable;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.util.Iterator;
 
-/** @author Drew Noakes http://drewnoakes.com */
+/**
+ * @author Drew Noakes https://drewnoakes.com
+ */
 public class StringUtil
 {
+    @NotNull
     public static String join(@NotNull Iterable<? extends CharSequence> strings, @NotNull String delimiter)
     {
@@ -50,4 +58,5 @@
     }
 
+    @NotNull
     public static <T extends CharSequence> String join(@NotNull T[] strings, @NotNull String delimiter)
     {
@@ -69,3 +78,38 @@
         return buffer.toString();
     }
+
+    @NotNull
+    public static String fromStream(@NotNull InputStream stream) throws IOException
+    {
+        BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
+        StringBuilder sb = new StringBuilder();
+        String line;
+        while ((line = reader.readLine()) != null) {
+            sb.append(line);
+        }
+        return sb.toString();
+    }
+
+    public static int compare(@Nullable String s1, @Nullable String s2)
+    {
+        boolean null1 = s1 == null;
+        boolean null2 = s2 == null;
+
+        if (null1 && null2) {
+            return 0;
+        } else if (null1) {
+            return -1;
+        } else if (null2) {
+            return 1;
+        } else {
+            return s1.compareTo(s2);
+        }
+    }
+
+    @NotNull
+    public static String urlEncode(@NotNull String name)
+    {
+        // Sufficient for now, it seems
+        return name.replace(" ", "%20");
+    }
 }
Index: trunk/src/com/drew/lang/annotations/NotNull.java
===================================================================
--- trunk/src/com/drew/lang/annotations/NotNull.java	(revision 6127)
+++ trunk/src/com/drew/lang/annotations/NotNull.java	(revision 8132)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2002-2012 Drew Noakes
+ * Copyright 2002-2015 Drew Noakes
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +16,6 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 
@@ -23,5 +23,5 @@
 
 /**
- * @author Drew Noakes http://drewnoakes.com
+ * @author Drew Noakes https://drewnoakes.com
  */
 public @interface NotNull
Index: trunk/src/com/drew/lang/annotations/Nullable.java
===================================================================
--- trunk/src/com/drew/lang/annotations/Nullable.java	(revision 6127)
+++ trunk/src/com/drew/lang/annotations/Nullable.java	(revision 8132)
@@ -1,4 +1,4 @@
 /*
- * Copyright 2002-2012 Drew Noakes
+ * Copyright 2002-2015 Drew Noakes
  *
  *    Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,6 +16,6 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 
@@ -23,5 +23,5 @@
 
 /**
- * @author Drew Noakes http://drewnoakes.com
+ * @author Drew Noakes https://drewnoakes.com
  */
 public @interface Nullable
Index: trunk/src/com/drew/lang/annotations/SuppressWarnings.java
===================================================================
--- trunk/src/com/drew/lang/annotations/SuppressWarnings.java	(revision 6127)
+++ trunk/src/com/drew/lang/annotations/SuppressWarnings.java	(revision 8132)
@@ -16,6 +16,6 @@
  * More information about this project is available at:
  *
- *    http://drewnoakes.com/code/exif/
- *    http://code.google.com/p/metadata-extractor/
+ *    https://drewnoakes.com/code/exif/
+ *    https://github.com/drewnoakes/metadata-extractor
  */
 
Index: trunk/src/com/drew/lang/annotations/package.html
===================================================================
--- trunk/src/com/drew/lang/annotations/package.html	(revision 8132)
+++ trunk/src/com/drew/lang/annotations/package.html	(revision 8132)
@@ -0,0 +1,34 @@
+<!--
+  ~ Copyright 2002-2015 Drew Noakes
+  ~
+  ~    Licensed under the Apache License, Version 2.0 (the "License");
+  ~    you may not use this file except in compliance with the License.
+  ~    You may obtain a copy of the License at
+  ~
+  ~        http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~    Unless required by applicable law or agreed to in writing, software
+  ~    distributed under the License is distributed on an "AS IS" BASIS,
+  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~    See the License for the specific language governing permissions and
+  ~    limitations under the License.
+  ~
+  ~ More information about this project is available at:
+  ~
+  ~    https://drewnoakes.com/code/exif/
+  ~    https://github.com/drewnoakes/metadata-extractor
+  -->
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+</head>
+<body bgcolor="white">
+
+Contains annotations used to extend the signatures of methods and fields, allowing tools such as IntelliJ IDEA
+to provide design-time warnings about potential run-time errors.
+
+<!-- Put @see and @since tags down here. -->
+
+</body>
+</html>
Index: trunk/src/com/drew/lang/package.html
===================================================================
--- trunk/src/com/drew/lang/package.html	(revision 8132)
+++ trunk/src/com/drew/lang/package.html	(revision 8132)
@@ -0,0 +1,33 @@
+<!--
+  ~ Copyright 2002-2015 Drew Noakes
+  ~
+  ~    Licensed under the Apache License, Version 2.0 (the "License");
+  ~    you may not use this file except in compliance with the License.
+  ~    You may obtain a copy of the License at
+  ~
+  ~        http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~    Unless required by applicable law or agreed to in writing, software
+  ~    distributed under the License is distributed on an "AS IS" BASIS,
+  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~    See the License for the specific language governing permissions and
+  ~    limitations under the License.
+  ~
+  ~ More information about this project is available at:
+  ~
+  ~    https://drewnoakes.com/code/exif/
+  ~    https://github.com/drewnoakes/metadata-extractor
+  -->
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+</head>
+<body bgcolor="white">
+
+Contains classes of generic utility.
+
+<!-- Put @see and @since tags down here. -->
+
+</body>
+</html>
