View Javadoc
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.DataOutputStream; 27 import java.io.OutputStream; 28 import java.io.IOException; 29 30 /*==================================================================== 31 Implementation of class GvDataOutputStream 32 ====================================================================*/ 33 /*** 34 * GvDataOutputStream writes to a DataOutputStream 35 * 36 * @version $Revision: 1.1.1.1 $ 37 * @author Frank Hardisty (hardisty@geog.psu.edu) 38 * @see DataOutputStream 39 */ 40 public class GvDataOutputStream extends DataOutputStream { 41 42 /*** 43 * Construct a newly created GvDataOutputStream 44 * 45 * @param in An InputStream. 46 */ 47 public GvDataOutputStream(OutputStream out) { 48 super(out); 49 } 50 51 /*** 52 * reads a short. Little Endian version. 53 */ 54 public void writeShortLE(int v) throws IOException{ 55 int ch1 = ((v >> 8) & 0xFF); // big 56 int ch2 = ((v >> 0) & 0xFF); // little 57 writeShort((ch2 << 8) + (ch1 << 0)); 58 } 59 60 public void writeCharLE(int v) throws IOException{ 61 int ch1 = ((v >> 8) & 0xFF); // big 62 int ch2 = ((v >> 0) & 0xFF); // little 63 writeChar((ch2 << 8) + (ch1 << 0)); 64 } 65 66 public void writeIntLE(int v) throws IOException{ 67 int ch1 = ((v >> 24) & 0xFF); // big 68 int ch2 = ((v >> 16) & 0xFF); 69 int ch3 = ((v >> 8) & 0xFF); 70 int ch4 = ((v >> 0) & 0xFF); // little 71 writeInt((ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0)); 72 } 73 public void writeLongLE(long v) throws IOException{ 74 int ch1 = (int) ((v >> 56) & 0xFF); // big 75 int ch2 = (int) ((v >> 48) & 0xFF); 76 int ch3 = (int) ((v >> 40) & 0xFF); 77 int ch4 = (int) ((v >> 32) & 0xFF); 78 int ch5 = (int) ((v >> 24) & 0xFF); 79 int ch6 = (int) ((v >> 16) & 0xFF); 80 int ch7 = (int) ((v >> 8) & 0xFF); 81 int ch8 = (int) ((v >> 0) & 0xFF); // little 82 writeLong((long)(((long)ch8 << 56) + 83 ((long)ch7 << 48) + 84 ((long)ch6 << 40) + 85 ((long)ch5 << 32) + 86 ((long)ch4 << 24) + 87 ((long)ch3 << 16) + 88 ((long)ch2 << 8) + 89 ((long)ch1 << 0))); 90 } 91 92 public void writeFloatLE(float v) throws IOException{ 93 writeIntLE(Float.floatToIntBits(v)); 94 } 95 96 public void writeDoubleLE(double v) throws IOException{ 97 writeLongLE(Double.doubleToLongBits(v)); 98 } 99 } 100

This page was automatically generated by Maven