com.jfimagine.utils.io
Class JFBinaryWriter

java.lang.Object
  |
  +--com.jfimagine.utils.io.JFBinaryWriter
All Implemented Interfaces:
JFWriter

public class JFBinaryWriter
extends java.lang.Object
implements JFWriter

JFBinaryWriter is a binary writer class to handle JFDraw files writing.

Version:
$Revision: 1.1 $
Author:
CookieMaker

Constructor Summary
JFBinaryWriter(java.io.DataOutputStream dataOutput)
          Constructor of JFBinaryWriter
 
Method Summary
 void write(byte[] b)
          Writes to the output stream all the bytes in array b.
 void write(byte[] b, int off, int len)
          Writes len bytes from array b, in order, to the output stream.
 void writeBoolean(boolean v)
          Writes a boolean value to this output stream.
 void writeByte(int v)
          Writes to the output stream the eight low- order bits of the argument v.
 void writeBytes(java.lang.String s)
          Writes a string to the output stream.
 void writeChar(int v)
          Writes a char value, wich is comprised of two bytes, to the output stream.
 void writeChars(java.lang.String s)
          Writes every character in the string s, to the output stream, in order, two bytes per character.
 void writeDouble(double v)
          Writes a double value, which is comprised of eight bytes, to the output stream.
 void writeFloat(float v)
          Writes a float value, which is comprised of four bytes, to the output stream.
 void writeInt(int v)
          Writes an int value, which is comprised of four bytes, to the output stream.
 void writeLong(long v)
          Writes a long value, which is comprised of eight bytes, to the output stream.
 void writeShort(int v)
          Writes two bytes to the output stream to represent the value of the argument.
 void writeUTF(java.lang.String str)
          Writes two bytes of length information to the output stream, followed by the Java modified UTF representation of every character in the string s.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JFBinaryWriter

public JFBinaryWriter(java.io.DataOutputStream dataOutput)
Constructor of JFBinaryWriter

Method Detail

write

public void write(byte[] b)
           throws java.io.IOException
Writes to the output stream all the bytes in array b.

Specified by:
write in interface JFWriter
Parameters:
b - the data.
Throws:
java.io.IOException - if an I/O error occurs.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Writes len bytes from array b, in order, to the output stream.

Specified by:
write in interface JFWriter
Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws:
java.io.IOException - if an I/O error occurs.

writeBoolean

public void writeBoolean(boolean v)
                  throws java.io.IOException
Writes a boolean value to this output stream. The byte written by this method may be read by the readBoolean method in JFReader.

Specified by:
writeBoolean in interface JFWriter
Parameters:
v - the boolean to be written.
Throws:
java.io.IOException - if an I/O error occurs.

writeByte

public void writeByte(int v)
               throws java.io.IOException
Writes to the output stream the eight low- order bits of the argument v. The 24 high-order bits of v are ignored.

Specified by:
writeByte in interface JFWriter
Parameters:
v - the byte value to be written.
Throws:
java.io.IOException - if an I/O error occurs.

writeShort

public void writeShort(int v)
                throws java.io.IOException
Writes two bytes to the output stream to represent the value of the argument. The bytes written by this method may be read by the readShort method in JFReader.

Specified by:
writeShort in interface JFWriter
Parameters:
v - the short value to be written.
Throws:
java.io.IOException - if an I/O error occurs.

writeChar

public void writeChar(int v)
               throws java.io.IOException
Writes a char value, wich is comprised of two bytes, to the output stream. The bytes written by this method may be read by the readChar method in JFReader.

Specified by:
writeChar in interface JFWriter
Parameters:
v - the char value to be written.
Throws:
java.io.IOException - if an I/O error occurs.

writeInt

public void writeInt(int v)
              throws java.io.IOException
Writes an int value, which is comprised of four bytes, to the output stream. The bytes written by this method may be read by the readInt method in JFReader.

Specified by:
writeInt in interface JFWriter
Parameters:
v - the int value to be written.
Throws:
java.io.IOException - if an I/O error occurs.

writeLong

public void writeLong(long v)
               throws java.io.IOException
Writes a long value, which is comprised of eight bytes, to the output stream. The bytes written by this method may be read by the readLong method in JFReader.

Specified by:
writeLong in interface JFWriter
Parameters:
v - the long value to be written.
Throws:
java.io.IOException - if an I/O error occurs.

writeFloat

public void writeFloat(float v)
                throws java.io.IOException
Writes a float value, which is comprised of four bytes, to the output stream. The bytes written by this method may be read by the readFloat method in JFReader.

Specified by:
writeFloat in interface JFWriter
Parameters:
v - the float value to be written.
Throws:
java.io.IOException - if an I/O error occurs.

writeDouble

public void writeDouble(double v)
                 throws java.io.IOException
Writes a double value, which is comprised of eight bytes, to the output stream. The bytes written by this method may be read by the readDouble method in JFReader.

Specified by:
writeDouble in interface JFWriter
Parameters:
v - the double value to be written.
Throws:
java.io.IOException - if an I/O error occurs.

writeBytes

public void writeBytes(java.lang.String s)
                throws java.io.IOException
Writes a string to the output stream. For every character in the string s, taken in order, one byte is written to the output stream.

Specified by:
writeBytes in interface JFWriter
Parameters:
s - the string of bytes to be written.
Throws:
java.io.IOException - if an I/O error occurs.

writeChars

public void writeChars(java.lang.String s)
                throws java.io.IOException
Writes every character in the string s, to the output stream, in order, two bytes per character.

Specified by:
writeChars in interface JFWriter
Parameters:
s - the string value to be written.
Throws:
java.io.IOException - if an I/O error occurs.

writeUTF

public void writeUTF(java.lang.String str)
              throws java.io.IOException
Writes two bytes of length information to the output stream, followed by the Java modified UTF representation of every character in the string s. The bytes written by this method may be read by the readUTF method in JFReader.

Specified by:
writeUTF in interface JFWriter
Parameters:
str - the string value to be written.
Throws:
java.io.IOException - if an I/O error occurs.


Copyright 2004 ~ 2005 JingFei International Cooperation LTD. All Rights Reserved.