1 /* -------------------------------------------------------------------
2 GeoVISTA Center (Penn State, Dept. of Geography)
3
4 Java source file for the class GvFileIOException
5
6 Copyright (c), 2000, GeoVISTA Center (Penn State, Dept. of Geography)
7 All Rights Reserved.
8
9 Original Author: Anonymous
10 $Author: jmacgill $
11
12 $Date: 2003/02/28 14:54:01 $
13
14 Reference: Document no:
15 ___ ___
16
17 To Do:
18 ___
19
20 ------------------------------------------------------------------- */
21
22 /* --------------------------- Package ---------------------------- */
23 package edu.psu.geovista.db.dbase;
24
25 /* ------------------ Import classes (packages) ------------------- *//package-summary/html">color="#329900"> ------------------ Import classes (packages) ------------------- *//package-summary.html">color="#329900">/* ------------------ Import classes (packages) ------------------- *//package-summary.html">color="#329900"> ------------------ Import classes (packages) ------------------- */
26 import java.io.DataInputStream;
27 import java.io.InputStream;
28 import java.io.IOException;
29
30 /*====================================================================
31 Implementation of class GvDataInputStream
32 ====================================================================*/
33 /***
34 * GvDataInputStream reads from a DataInputStream
35 *
36 * @version $Revision: 1.1.1.1 $
37 * @author Frank Hardisty (hardisty@geog.psu.edu)
38 * @see DataInputStream
39 */
40
41 public class GvDataInputStream extends DataInputStream {
42 private transient byte[] c = new byte[8];
43
44 /***
45 * Construct a newly created GvDataInputStream
46 *
47 * @param in An InputStream.
48 */
49 public GvDataInputStream(InputStream in) {
50 super(in);
51 }
52
53 /***
54 * reads a short. Little Endian version.
55 *
56 * it uses "readFully" meathod instead of reading each byte.
57 * <pre>
58 * readFully(c, 0, 2) is probably faster and use less memory than
59 * int ch1 = read();
60 * int ch2 = read();
61 * return (short)((ch2 << 8) + (ch1 << 0));
62 * </pre>
63 */
64 public final short readShortLE() throws IOException {
65 readFully(c, 0, 2);
66 return (short)(((c[1] & 0xFF) << 8) | (c[0] & 0xFF));
67 }
68
69 public final char readCharLE() throws IOException {
70 return (char)readShortLE();
71 }
72
73 public int readIntLE() throws IOException{
74 readFully(c, 0, 4);
75 return (((c[3]) << 24) |
76 ((c[2] & 0xFF) << 16) |
77 ((c[1] & 0xFF) << 8) |
78 ((c[0] & 0xFF)));
79 }
80
81 public long readLongLE() throws IOException{
82 return ((long)readIntLE() + ((long)readIntLE() << 32));
83 }
84
85 public float readFloatLE() throws IOException{
86 return Float.intBitsToFloat(readIntLE());
87 }
88
89 public double readDoubleLE() throws IOException{
90 return Double.longBitsToDouble(readLongLE());
91 }
92 }
This page was automatically generated by Maven