1 /* Copyright (C) 2003 Vladimir Roubtsov. All rights reserved. 2 * 3 * This program and the accompanying materials are made available under 4 * the terms of the Common Public License v1.0 which accompanies this distribution, 5 * and is available at http://www.eclipse.org/legal/cpl-v10.html 6 * 7 * $Id: UDataOutputStream.java,v 1.1.1.1.2.1 2004/07/10 03:34:53 vlad_r Exp $ 8 */ 9 package com.vladium.jcd.lib; 10 11 import java.io.DataOutputStream; 12 import java.io.IOException; 13 import java.io.OutputStream; 14 15 // ---------------------------------------------------------------------------- 16 /** 17 * A trivial extension to java.io.DataInputStream to provide methods for 18 * writing unsigned 16- and 32-bit integers with simple mnemonics. It uses 19 * correspondingly wider native types to preserve the full range of the unsigned 20 * types. 21 * 22 * @author (C) 2001, Vlad Roubtsov 23 */ 24 public 25 final class UDataOutputStream extends DataOutputStream 26 { 27 // public: ................................................................ 28 29 UDataOutputStream(final OutputStream _out)30 public UDataOutputStream (final OutputStream _out) 31 { 32 super (_out); 33 } 34 35 writeU2(final int uint)36 public final void writeU2 (final int uint) throws IOException 37 { 38 writeShort ((short) uint); // this narrowing cast is Ok 39 } 40 41 writeU4(final long ulong)42 public final void writeU4 (final long ulong) throws IOException 43 { 44 writeInt ((int) ulong); // this narrowing cast is Ok 45 } 46 47 // protected: ............................................................. 48 49 // package: ............................................................... 50 51 // private: ............................................................... 52 53 } // end of class 54 // ---------------------------------------------------------------------------- 55