📄 jfbinarywriter.java
字号:
/**
* $Id: JFBinaryWriter.java $
*
* Copyright 2004 ~ 2005 JingFei International Cooperation LTD. All rights reserved.
*
*/
package com.jfimagine.utils.io;
import java.io.IOException;
import java.io.DataOutputStream;
/**
* JFBinaryWriter is a binary writer class to handle JFDraw files writing.
*
* @author CookieMaker
*
* @version $Revision: 1.6.0 $
*/
public class JFBinaryWriter implements JFWriter{
/**A data output object to read data*/
private DataOutputStream m_dataOutput;
/**
* Constructor of JFBinaryWriter
*
*
*/
public JFBinaryWriter(DataOutputStream dataOutput){
m_dataOutput =dataOutput;
}
/**
* Writes to the output stream all the bytes in array <code>b</code>.
*
* @param b the data.
* @exception IOException if an I/O error occurs.
*/
public void write(byte b[]) throws IOException{
m_dataOutput.write(b);
}
/**
* Writes <code>len</code> bytes from array
* <code>b</code>, in order, to
* the output stream.
*
* @param b the data.
* @param off the start offset in the data.
* @param len the number of bytes to write.
* @exception IOException if an I/O error occurs.
*/
public void write(byte b[], int off, int len) throws IOException{
m_dataOutput.write(b,off,len);
}
/**
* Writes a <code>boolean</code> value to this output stream.
*
* The byte written by this method may
* be read by the <code>readBoolean</code>
* method in JFReader.
*
* @param v the boolean to be written.
* @exception IOException if an I/O error occurs.
*/
public void writeBoolean(boolean v) throws IOException{
m_dataOutput.writeBoolean(v);
}
/**
* Writes to the output stream the eight low-
* order bits of the argument <code>v</code>.
* The 24 high-order bits of <code>v</code>
* are ignored.
*
* @param v the byte value to be written.
* @exception IOException if an I/O error occurs.
*/
public void writeByte(int v) throws IOException{
m_dataOutput.writeByte(v);
}
/**
* 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 <code>readShort</code> method in JFReader.
*
* @param v the <code>short</code> value to be written.
* @exception IOException if an I/O error occurs.
*/
public void writeShort(int v) throws IOException{
m_dataOutput.writeShort(v);
}
/**
* Writes a <code>char</code> value, wich
* is comprised of two bytes, to the
* output stream.
* The bytes written by this method may be
* read by the <code>readChar</code> method in JFReader.
*
* @param v the <code>char</code> value to be written.
* @exception IOException if an I/O error occurs.
*/
public void writeChar(int v) throws IOException{
m_dataOutput.writeChar(v);
}
/**
* Writes an <code>int</code> value, which is
* comprised of four bytes, to the output stream.
* The bytes written by this method may be read
* by the <code>readInt</code> method in JFReader.
*
* @param v the <code>int</code> value to be written.
* @exception IOException if an I/O error occurs.
*/
public void writeInt(int v) throws IOException{
m_dataOutput.writeInt(v);
}
/**
* Writes a <code>long</code> value, which is
* comprised of eight bytes, to the output stream.
* The bytes written by this method may be
* read by the <code>readLong</code> method in JFReader.
*
* @param v the <code>long</code> value to be written.
* @exception IOException if an I/O error occurs.
*/
public void writeLong(long v) throws IOException{
m_dataOutput.writeLong(v);
}
/**
* Writes a <code>float</code> value,
* which is comprised of four bytes, to the output stream.
* The bytes written by this method
* may be read by the <code>readFloat</code>
* method in JFReader.
*
* @param v the <code>float</code> value to be written.
* @exception IOException if an I/O error occurs.
*/
public void writeFloat(float v) throws IOException{
m_dataOutput.writeFloat(v);
}
/**
* Writes a <code>double</code> value,
* which is comprised of eight bytes, to the output stream.
* The bytes written by this method
* may be read by the <code>readDouble</code>
* method in JFReader.
*
* @param v the <code>double</code> value to be written.
* @exception IOException if an I/O error occurs.
*/
public void writeDouble(double v) throws IOException{
m_dataOutput.writeDouble(v);
}
/**
* Writes a string to the output stream.
* For every character in the string
* <code>s</code>, taken in order, one byte
* is written to the output stream.
*
* @param s the string of bytes to be written.
* @exception IOException if an I/O error occurs.
*/
public void writeBytes(String s) throws IOException{
m_dataOutput.writeBytes(s);
}
/**
* Writes every character in the string <code>s</code>,
* to the output stream, in order,
* two bytes per character.
*
* @param s the string value to be written.
* @exception IOException if an I/O error occurs.
*/
public void writeChars(String s) throws IOException{
m_dataOutput.writeChars(s);
}
/**
* Writes two bytes of length information
* to the output stream, followed
* by the Java modified UTF representation
* of every character in the string <code>s</code>.
*
* The bytes written by this method may be read
* by the <code>readUTF</code> method in JFReader.
*
* @param str the string value to be written.
* @exception IOException if an I/O error occurs.
*/
public void writeUTF(String str) throws IOException{
m_dataOutput.writeUTF(str);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -