java.io

Class DataOutputStream

Implemented Interfaces:
Closeable, DataOutput, Flushable

public class DataOutputStream
extends FilterOutputStream
implements DataOutput

A data output stream lets an application write primitive Java data types to an output stream in a portable way. An application can then use a data input stream to read the data back in.
Since:
JDK1.0
See Also:
DataInputStream

Field Summary

protected int
written
The number of bytes written to the data output stream so far.

Fields inherited from class java.io.FilterOutputStream

out

Constructor Summary

DataOutputStream(OutputStream out)
Creates a new data output stream to write data to the specified underlying output stream.

Method Summary

void
flush()
Flushes this data output stream.
int
size()
Returns the current value of the counter written, the number of bytes written to this data output stream so far.
void
write(b[] , int off, int len)
Writes len bytes from the specified byte array starting at offset off to the underlying output stream.
void
write(int b)
Writes the specified byte (the low eight bits of the argument b) to the underlying output stream.
void
writeBoolean(boolean v)
Writes a boolean to the underlying output stream as a 1-byte value.
void
writeByte(int v)
Writes out a byte to the underlying output stream as a 1-byte value.
void
writeBytes(String s)
Writes out the string to the underlying output stream as a sequence of bytes.
void
writeChar(int v)
Writes a char to the underlying output stream as a 2-byte value, high byte first.
void
writeChars(String s)
Writes a string to the underlying output stream as a sequence of characters.
void
writeDouble(double v)
Converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the underlying output stream as an 8-byte quantity, high byte first.
void
writeFloat(float v)
Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the underlying output stream as a 4-byte quantity, high byte first.
void
writeInt(int v)
Writes an int to the underlying output stream as four bytes, high byte first.
void
writeLong(long v)
Writes a long to the underlying output stream as eight bytes, high byte first.
void
writeShort(int v)
Writes a short to the underlying output stream as two bytes, high byte first.
void
writeUTF(String str)
Writes a string to the underlying output stream using modified UTF-8 encoding in a machine-independent manner.

Methods inherited from class java.io.FilterOutputStream

close, flush, write, write, write

Methods inherited from class java.io.OutputStream

close, flush, write, write, write

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

written

protected int written
The number of bytes written to the data output stream so far. If this counter overflows, it will be wrapped to Integer.MAX_VALUE.

Constructor Details

DataOutputStream

public DataOutputStream(OutputStream out)
Creates a new data output stream to write data to the specified underlying output stream. The counter written is set to zero.
Parameters:
out - the underlying output stream, to be saved for later use.
Usages and Demos :

View More Examples of DataOutputStream(OutputStream out)
   1:         if (args.length == 1){
   2:             return new DataOutputStream((OutputStream)args[0]);
   3:         } else {
   4:             undefined(args, context);
   5:             return null;

View Full Code Here
   1:     bs.reset();
   2:     DataOutputStream ds = new DataOutputStream(bs);
   3: 
   4:     for (int i = 0; i < in.length; i += 2) {
   5:         byte high = (byte) Base16.indexOf(Character.toUpperCase((char)in[i]));

View Full Code Here
   1:     bs.reset();
   2:     DataOutputStream ds = new DataOutputStream(bs);
   3: 
   4:     for (int i = 0; i < (in.length + 3) / 4; i++) {
   5:         short [] s = new short[4];

View Full Code Here
   1:         ByteArrayOutputStream hbs = new ByteArrayOutputStream();
   2:         DataOutputStream hos = new DataOutputStream(hbs);
   3:         hos.writeInt(protocolVersion);
   4:         ...
   5:         ByteArrayOutputStream gbs = new ByteArrayOutputStream();
   6:         DataOutputStream gos = new DataOutputStream(gbs);
   7:         gos.writeUTF(groups[i]);
   8:         ...
   9:             new ByteArrayOutputStream(maxPacketSize);
  10:         DataOutputStream os = new DataOutputStream(bs);
  11:         os.write(marshaledHeader);

View Full Code Here
   1:         {
   2:             doutput = new DataOutputStream(buffer);
   3:         }
   4:         return doutput;
   5:     }

View Full Code Here

Method Details

flush

public void flush()
            throws IOException
Flushes this data output stream. This forces any buffered output bytes to be written out to the stream.

The flush method of DataOutputStream calls the flush method of its underlying output stream.

Specified by:
flush in interface Flushable
Overrides:
flush in interface FilterOutputStream
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of flush()
   1:             File f = new File("test2.txt");
   2:         DataOutputStream dos;
   3:             try 
   4:         ...
   5:             {
   6:                     dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(f)));
   7:                     dos.writeChars("this is a test !!!!! ");
   8:         ...
   9:                     dos.flush();
  10:               dos.close();

View Full Code Here
   1:     File f = new File("test.txt");
   2:     DataOutputStream dos;
   3:     
   4:         ...
   5:             {
   6:                     dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(f)));
   7:                     dos.writeChars("hello , this is something test!!!");
   8:         ...
   9:                     dos.flush();
  10:                     g.drawString("test successfully !!!!!", 10, 10);

View Full Code Here
   1:     File f = new File(myFile);
   2:     DataOutputStream dos;
   3: 
   4:         ...
   5:     try {
   6:         dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(myFile),128));
   7:       dos.writeChars("Cats can hypnotize you when you least expect it\n");
   8:         ...
   9:       dos.flush();
  10:       g.drawString("Successfully wrote to the file named " + myFile + " -- go take a look at it!", 10, 10);

View Full Code Here
   1:         try {
   2:             DataOutputStream dos =
   3:         ...
   4:                    new DataOutputStream(data.getOutputStream());
   5:             dos.writeByte(TypeServerConstants.WELCOME);
   6:         ...
   7:                 dos.writeUTF("Thisisateststring");
   8:                 dos.flush();
   9:             }

View Full Code Here
   1:         try {
   2:             DataOutputStream dos =
   3:         ...
   4:                    new DataOutputStream(data.getOutputStream());
   5:             dos.writeByte(TypeServerConstants.WELCOME);
   6:         ...
   7:             dos.writeUTF("Thisisateststring");
   8:             dos.flush();
   9:         } catch (Exception e) {

View Full Code Here

size

public final int size()
Returns the current value of the counter written, the number of bytes written to this data output stream so far. If the counter overflows, it will be wrapped to Integer.MAX_VALUE.
Returns:
the value of the written field.
See Also:
written
Usages and Demos :

View More Examples of size()
   1: 
   2:     DataOutputStream file;
   3: 
   4:         ...
   5:     {
   6:         file = new DataOutputStream(new BufferedOutputStream(stream));
   7:     }
   8:         ...
   9:     {
  10:         return file.size();
  11:     }
  12:         ...
  13:     {
  14:         return file.size();

View Full Code Here
   1: 
   2:       DataOutputStream primesStream = new DataOutputStream(
   3:                 new BufferedOutputStream(new FileOutputStream(primesFile)));
   4:         ...
   5: 
   6:       System.out.println("File size = " + primesStream.size());
   7:     }
   8:     {
   9:       System.out.println("IOException " + e + " occurred");

View Full Code Here
   1: 
   2:       DataOutputStream myFile = new DataOutputStream(
   3:                                 new BufferedOutputStream(myZipFile));
   4:         ...
   5: 
   6:       System.out.println("File size = " + myFile.size());
   7:       System.out.println("Compressed file size = " +
   8:                                           myZipEntry.getCompressedSize());
   9:     }

View Full Code Here
   1: 
   2:     DataOutputStream mainOutput;
   3:         ...
   4:     DataOutputStream extraOutput;
   5:     FileOutputStream mainFileOutput = null;
   6:         ...
   7:     private int getExtraDataPosition() {
   8:         return extraOutput.size();
   9:     }
  10:         ...
  11:             mainFileOutput = new FileOutputStream(mainDataFile);
  12:             mainOutput = new DataOutputStream(new BufferedOutputStream(mainFileOutput));

View Full Code Here
   1:             return cur.intValue();
   2:         objectTable.put(object, new Integer(objectTable.size()));
   3:         ...
   4:         return (objectTable.size() - 1);
   5:     }
   6:         ...
   7: 
   8:     private boolean writePrefix(Object object, DataOutputStream out) throws IOException {
   9:         if (writeIndex(object, out))
  10:         ...
  11: 
  12:     private void writeStateDeprecated(StateImpl state, DataOutputStream out) throws IOException {

View Full Code Here

write

public void write(b[] ,
                  int off,
                  int len)
            throws IOException
Writes len bytes from the specified byte array starting at offset off to the underlying output stream. If no exception is thrown, the counter written is incremented by len.
Specified by:
write in interface DataOutput
Overrides:
write in interface FilterOutputStream
Parameters:
off - the start offset in the data.
len - the number of bytes to write.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of write(b[] ,int off,int len)
   1: 
   2:   void write(DataOutputStream out) throws IOException {
   3:     out.writeShort(attrName().getIndex());
   4:         ...
   5:     out.writeInt(attributeBytes.length);
   6:     out.write(attributeBytes, 0, attributeBytes.length);
   7:   }
   8: 
   9:   void print(PrintStream out, int indent) {

View Full Code Here
   1: import java.io.ByteArrayOutputStream;
   2: import java.io.DataOutputStream;
   3: import java.io.IOException;
   4:         ...
   5:             ByteArrayOutputStream sink = new ByteArrayOutputStream(64);
   6:             DataOutputStream out = new DataOutputStream(new DigestOutputStream(sink, md));
   7:         ...
   8:             out.write(addr, 0, addr.length);
   9:             out.flush();

View Full Code Here
   1: import java.net.Socket;
   2: import java.io.DataOutputStream;
   3: import java.io.BufferedReader;
   4:         ...
   5:     m_output.writeBytes(command);
   6:     m_output.write(CRLF, 0, CRLF.length);
   7:     m_output.flush();
   8:         ...
   9:     m_output.writeBytes(command);
  10:     m_output.write(CRLF, 0, CRLF.length);
  11:     m_output.flush();
  12:         ...
  13:         m_output.writeBytes(data[i]);
  14:         m_output.write(CRLF, 0, CRLF.length);

View Full Code Here
   1: 
   2: import java.io.DataOutputStream;
   3: import java.io.ByteArrayOutputStream;
   4:         ...
   5:         new java.io.ByteArrayOutputStream(16);
   6:         DataOutputStream dos=new 
   7:         ...
   8:         DataOutputStream(baos);
   9:             
  10:         ...
  11:         dos.write(_header,0,_header.length);

View Full Code Here
   1: import java.io.DataInputStream;
   2: import java.io.DataOutputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:   private DataOutputStream _outStream;
   7: 
   8:         ...
   9: 
  10:   private DataOutputStream _doStream;
  11: 
  12:         ...
  13:       {
  14:     _outStream.write(_HANDSHAKE, 0, _HANDSHAKE.length);

View Full Code Here

write

public void write(int b)
            throws IOException
Writes the specified byte (the low eight bits of the argument b) to the underlying output stream. If no exception is thrown, the counter written is incremented by 1.

Implements the write method of OutputStream.

Specified by:
write in interface DataOutput
Overrides:
write in interface FilterOutputStream
Parameters:
b - the byte to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of write(int b)
   1:     {
   2:     DataOutputStream out = new DataOutputStream(socket.getOutputStream());
   3:     String request = method + " " + url.getFile() + " HTTP/1.0\r\n";
   4:         ...
   5:     out.write(request.getBytes());
   6:     String agent = "User-Agent: Kaffe-HttpURLConnection/0.10\r\n";
   7:         ...
   8:     out.write(agent.getBytes());
   9:         ...
  10:     out.write("\r\n".getBytes());

View Full Code Here
   1:     int size = items != null ? items.size() : 0;
   2:     DataOutputStream os = (DataOutputStream)protocol.getOutputStream();
   3: 
   4:         ...
   5:     for (int i=0; i < size; i++) {
   6:         os.write(' ');
   7: 
   8:         ...
   9:         } else if (o instanceof Argument) {
  10:         ((Argument)o).write(protocol);
  11:         }
  12:         ...
  13:             throws IOException, ProtocolException {
  14:     DataOutputStream os = (DataOutputStream)protocol.getOutputStream();

View Full Code Here
   1:     DataInputStream in;
   2:     DataOutputStream out;
   3:     String outputFile;
   4:         ...
   5:         for (int i = 0; i < 8; i++) {
   6:             out.write((((d << i) & 0x80) == 0) ? '0' : '1');
   7:         }
   8:         ...
   9:         out.write(' ');
  10:     }
  11:         ...
  12:         try {
  13:             out.write(((c0 << 2) & 0xfc) | ((c1 >> 4) & 0x3));

View Full Code Here
   1: 
   2:     private DataOutputStream output;
   3: 
   4:         ...
   5:     traceOutput.setQuote(quote);
   6:     output = new DataOutputStream(new BufferedOutputStream(traceOutput));
   7:     }
   8:         ...
   9:     traceOutput.setQuote(quote);
  10:     output = new DataOutputStream(new BufferedOutputStream(traceOutput));
  11: 
  12:         ...
  13:     if (args != null) {
  14:         output.write(' ');

View Full Code Here
   1: import java.awt.image.BufferedImage;
   2: import java.io.DataOutputStream;
   3: import java.util.Hashtable;
   4:         ...
   5: 
   6:     private void a(int ai[], int j, DataOutputStream dataoutputstream) throws Exception
   7:     {
   8:         ...
   9:                     dataoutputstream.writeByte(255);
  10:                     dataoutputstream.write(abyte0);
  11:                     abyte0[i1 = 0] = (byte)j2;
  12:         ...
  13:                                 dataoutputstream.writeByte(255);
  14:                                 dataoutputstream.write(abyte0);

View Full Code Here

writeBoolean

public final void writeBoolean(boolean v)
            throws IOException
Writes a boolean to the underlying output stream as a 1-byte value. The value true is written out as the value (byte)1; the value false is written out as the value (byte)0. If no exception is thrown, the counter written is incremented by 1.
Specified by:
writeBoolean in interface DataOutput
Parameters:
v - a boolean value to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeBoolean(boolean v)
   1: 
   2:     public void pickle(DataOutputStream out, Object b) 
   3:     throws IOException
   4:         ...
   5:     {
   6:     out.writeBoolean(((Boolean) b).booleanValue()) ;
   7:     }
   8: 

View Full Code Here
   1: 
   2:   public void writeToStream(DataOutputStream out, Scene theScene) throws IOException
   3:   {
   4:         ...
   5:     out.writeBoolean(abs);
   6:   }
   7:   

View Full Code Here
   1: 
   2:     public static void outputObject(Object obj, DataOutputStream out) throws IOException {
   3:         if (obj instanceof XMLRootObject) {
   4:         ...
   5:             out.writeInt(BooleanType);
   6:             out.writeBoolean(((Boolean) obj).booleanValue());
   7: 
   8:         ...
   9: 
  10:     private static void writeString(DataOutputStream out, String str) throws IOException {
  11:         out.writeInt(str.length());

View Full Code Here
   1: import java.util.Vector;
   2: import java.io.DataOutputStream;
   3: import java.io.BufferedOutputStream;
   4:         ...
   5:     String table, fileName;
   6:     DataOutputStream streamOut;
   7:     for(int i = 0;;)
   8:         ...
   9:         fileName = abd.chemin + table + ".dat";
  10:         streamOut = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(fileName)));
  11: 
  12:         ...
  13:             bit = rs.getBoolean(i);
  14:             streamOut.writeBoolean(bit);

View Full Code Here
   1: import java.io.ByteArrayOutputStream;
   2: import java.io.DataOutputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:    protected DataOutputStream outputStream;
   7: 
   8:         ...
   9:    public AMFSerializer(DataOutputStream outputStream)
  10:    {
  11:         ...
  12:          outputStream.writeByte(AMFBody.DATA_TYPE_BOOLEAN);
  13:          outputStream.writeBoolean(((Boolean) value).booleanValue());

View Full Code Here

writeByte

public final void writeByte(int v)
            throws IOException
Writes out a byte to the underlying output stream as a 1-byte value. If no exception is thrown, the counter written is incremented by 1.
Specified by:
writeByte in interface DataOutput
Parameters:
v - a byte value to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeByte(int v)
   1: 
   2: import java.io.DataOutputStream;
   3: import java.io.ByteArrayOutputStream;
   4:         ...
   5:         new java.io.ByteArrayOutputStream(16);
   6:         DataOutputStream dos=new 
   7:         ...
   8:         DataOutputStream(baos);
   9:             
  10:         ...
  11:         DataOutputStream dos=new DataOutputStream(baos);
  12:         dos.writeByte('P');

View Full Code Here
   1: import java.io.ByteArrayOutputStream;
   2: import java.io.DataOutputStream;
   3: import java.io.IOException;
   4:         ...
   5: {
   6:     abstract void Write(DataOutputStream dos) throws IOException;
   7: }
   8:         ...
   9: 
  10:     void Write(DataOutputStream dos) throws IOException
  11:     {
  12:         ...
  13:         dos.writeByte(Constant.Class);

View Full Code Here

writeBytes

public final void writeBytes(String s)
            throws IOException
Writes out the string to the underlying output stream as a sequence of bytes. Each character in the string is written out, in sequence, by discarding its high eight bits. If no exception is thrown, the counter written is incremented by the length of s.
Specified by:
writeBytes in interface DataOutput
Parameters:
s - a string of bytes to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeBytes(String s)
   1: 
   2: import java.io.DataOutputStream;
   3: import java.io.FileOutputStream;
   4:         ...
   5:       FileOutputStream newFos = new FileOutputStream(filename, true);
   6:       DataOutputStream newDos = new DataOutputStream(newFos);
   7:         ...
   8:       newDos.writeBytes("**" + dateString + "**:" + record + "\n");
   9:       newDos.close();

View Full Code Here
   1:     BufferedOutputStream bos = null;
   2:     DataOutputStream dos = null;
   3:     try {
   4:         ...
   5:       bos = new BufferedOutputStream(ostr);
   6:       dos = new DataOutputStream(bos);
   7:       for (int i=0; i<xpos.length; i++) {
   8:         ...
   9:         dos.writeBytes("" + xpos[i] + "\t" + ypos[i] + "\n");
  10:       }

View Full Code Here
   1: 
   2:   public void from(IclTerm originalTerm, DataOutputStream dos) throws IOException
   3:   {
   4:         ...
   5:       if(preChild != null) {
   6:         dos.writeBytes(preChild);
   7:       }
   8:         ...
   9:       case OaaPrologVocabTokenTypes.LIST:
  10:         dos.writeBytes("[");
  11:         numArgs = currentTerm.size();
  12:         ...
  13:         numArgs = currentTerm.size();
  14:         dos.writeBytes(functor);

View Full Code Here
   1:     public ZObjectOutputStream(OutputStream out) {
   2:     dos = new DataOutputStream(out);
   3:     objs = new Hashtable();
   4:         ...
   5: 
   6:     dos.writeBytes("#JAZZ1.0");
   7:         ...
   8:     dos.writeBytes("\n");
   9:     addObject(obj);
  10:         ...
  11: 
  12:     dos.writeBytes("[\n");

View Full Code Here
   1:   FileOutputStream fileOutStream = null;
   2:   DataOutputStream dataOutStream = null;
   3:     
   4:         ...
   5:     
   6:   dataOutStream = new DataOutputStream(fileOutStream);
   7: 
   8:         ...
   9:             dataOutStream.writeBytes("package com.tymeac.common;" + crlf);    
  10:             dataOutStream.writeBytes("  " + crlf);
  11:             dataOutStream.writeBytes("public class TyVariables {" + crlf);    
  12:         ...
  13:                     dataOutStream.writeBytes("  private static String  tymeac_alternate_class_name = " + "\"" + F_alt_name + "\""  + ";"  +  crlf);
  14:                     dataOutStream.writeBytes("  " + crlf);            

View Full Code Here

writeChar

public final void writeChar(int v)
            throws IOException
Writes a char to the underlying output stream as a 2-byte value, high byte first. If no exception is thrown, the counter written is incremented by 2.
Specified by:
writeChar in interface DataOutput
Parameters:
v - a char value to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeChar(int v)
   1:     {
   2:         DataOutputStream outputStream =
   3:         ...
   4:         new DataOutputStream(new FileOutputStream("results.dat"));
   5: 
   6:         ...
   7:             if (r >= 0.5)
   8:             outputStream.writeChar( (int) 'F' );
   9:             else
  10:         ...
  11:             outputStream.writeChar( (int) 'T' );

View Full Code Here
   1: 
   2:       DataOutputStream dos =
   3:         ...
   4:         new DataOutputStream(fos);
   5: 
   6:         ...
   7:       dos.writeByte(Byte.MAX_VALUE);
   8:       dos.writeChar('A');
   9:       dos.writeDouble(Double.MAX_VALUE);

View Full Code Here
   1:       FileOutputStream outFileStream  = new FileOutputStream( outFile );
   2:       DataOutputStream outDataStream  = new DataOutputStream( outFileStream );
   3: 
   4:         ...
   5:       outDataStream.writeDouble(3333333D);
   6:       outDataStream.writeChar('A');
   7:       outDataStream.writeBoolean(true);
   8: 
   9:       outDataStream.close();

View Full Code Here
   1:         FileOutputStream fos = new FileOutputStream("a.txt");
   2:         DataOutputStream dos = new DataOutputStream (fos);
   3:         try
   4:         ...
   5:             dos.writeByte((byte)123);
   6:             dos.writeChar('J');
   7:             dos.writeDouble(3.141592654);
   8:             dos.writeFloat(2.7182f);
   9:             dos.writeInt(1234567890);

View Full Code Here
   1: 
   2:         DataOutputStream out = new DataOutputStream(new
   3:                    FileOutputStream("invoice1.txt"));
   4:         ...
   5:             out.writeDouble(prices[i]);
   6:             out.writeChar('\t');
   7:             out.writeInt(units[i]);
   8:         ...
   9:             out.writeChar('\t');
  10:             out.writeChars(descs[i]);
  11:         ...
  12:             out.writeChar('\n');

View Full Code Here

writeChars

public final void writeChars(String s)
            throws IOException
Writes a string to the underlying output stream as a sequence of characters. Each character is written to the data output stream as if by the writeChar method. If no exception is thrown, the counter written is incremented by twice the length of s.
Specified by:
writeChars in interface DataOutput
Parameters:
s - a String value to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeChars(String s)
   1: 
   2:       DataOutputStream myStream = new DataOutputStream(
   3:                                     new FileOutputStream(aFile));
   4:     }
   5:     catch(IOException e)

View Full Code Here
   1: 
   2:         DataOutputStream out = new DataOutputStream(new
   3:                    FileOutputStream("invoice1.txt"));
   4:         ...
   5:             out.writeChar('\t');
   6:             out.writeChars(descs[i]);
   7:             out.writeChar('\n');
   8:         }
   9:         out.close();

View Full Code Here
   1: {
   2:         DataOutputStream out = new DataOutputStream(new
   3:                    FileOutputStream("content.txt"));
   4:         ...
   5:             out.writeChar('\t');
   6:             out.writeChars(descs[i]);
   7:             out.writeChar('\n');
   8:         }
   9:         out.close();

View Full Code Here
   1:     {
   2:             DataOutputStream out = new DataOutputStream(new
   3:                    FileOutputStream("invoice1.txt"));
   4:         ...
   5:                     out.writeChar('\t');
   6:                     out.writeChars(descs[i]);
   7:                     out.writeChar('\n');
   8:             }
   9:             out.close();

View Full Code Here
   1: 
   2: import java.io.DataOutputStream;
   3: import java.io.ByteArrayOutputStream;
   4:         ...
   5: 
   6:     private DataOutputStream out1;
   7: 
   8:         ...
   9:         if (useUnicode)
  10:             out1 = new DataOutputStream(_out);
  11: 
  12:         ...
  13: 
  14:         out1.writeChars(str);

View Full Code Here

writeDouble

public final void writeDouble(double v)
            throws IOException
Converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the underlying output stream as an 8-byte quantity, high byte first. If no exception is thrown, the counter written is incremented by 8.
Specified by:
writeDouble in interface DataOutput
Parameters:
v - a double value to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeDouble(double v)
   1:   throws IOException {
   2:     DataOutputStream out = new DataOutputStream(
   3:       new BufferedOutputStream(
   4:         ...
   5:         new FileOutputStream("Data.txt")));
   6:     out.writeDouble(3.14159);
   7:     out.writeUTF("That was pi");
   8:         ...
   9:     out.writeDouble(1.41413);
  10:     out.writeUTF("Square root of 2");

View Full Code Here
   1: 
   2:     public final void pickle(DataOutputStream out, Object d) 
   3:     throws IOException
   4:         ...
   5:     {
   6:     out.writeDouble(((Double) d).doubleValue()) ;
   7:     }
   8: 

View Full Code Here
   1:         {
   2:             DataOutputStream out=new DataOutputStream(new BufferedOutputStream(new FileOutputStream("Data.txt")));
   3:         ...
   4:             out.writeDouble(3.1232134);
   5:             out.writeChars("that was pi\n");
   6:             out.writeBytes("that was pi\n");
   7:             out.write

View Full Code Here
   1: import java.io.ByteArrayOutputStream;
   2: import java.io.DataOutputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:    protected DataOutputStream outputStream;
   7: 
   8:         ...
   9:    public AMFSerializer(DataOutputStream outputStream)
  10:    {
  11:         ...
  12:          outputStream.writeByte(AMFBody.DATA_TYPE_NUMBER);
  13:          outputStream.writeDouble(((Number) value).doubleValue());

View Full Code Here
   1: import java.io.DataOutput;
   2: import java.io.DataOutputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     static  public void marshalPrimitiveMap(HashMap map, DataOutputStream out) throws IOException {
   7:         if( map == null ) {
   8:         ...
   9: 
  10:     static public void marshalPrimitive(DataOutputStream out, Object value) throws IOException {
  11:         if( value == null ) {
  12:         ...
  13:             out.writeByte(DOUBLE_TYPE);
  14:             out.writeDouble(((Double)value).doubleValue());

View Full Code Here

writeFloat

public final void writeFloat(float v)
            throws IOException
Converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the underlying output stream as a 4-byte quantity, high byte first. If no exception is thrown, the counter written is incremented by 4.
Specified by:
writeFloat in interface DataOutput
Parameters:
v - a float value to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeFloat(float v)
   1:       FileOutputStream outFileStream  = new FileOutputStream( outFile );
   2:       DataOutputStream outDataStream  = new DataOutputStream( outFileStream );
   3: 
   4:         ...
   5:       outDataStream.writeLong(11111111L);
   6:       outDataStream.writeFloat(22222222F);
   7:       outDataStream.writeDouble(3333333D);
   8:       outDataStream.writeChar('A');
   9:       outDataStream.writeBoolean(true);

View Full Code Here
   1:         FileOutputStream fos = new FileOutputStream("a.txt");
   2:         DataOutputStream dos = new DataOutputStream (fos);
   3:         try
   4:         ...
   5:             dos.writeDouble(3.141592654);
   6:             dos.writeFloat(2.7182f);
   7:             dos.writeInt(1234567890);
   8:             dos.writeLong(998877665544332211L);
   9:             dos.writeShort((short)11223);

View Full Code Here
   1:   }    
   2:   public final void dump(DataOutputStream file) throws IOException
   3:   {
   4:         ...
   5:     file.writeByte(tag);
   6:     file.writeFloat(bytes);
   7:   }    
   8:   public final float getBytes() { return bytes; }    
   9:   public final void setBytes(float bytes) {

View Full Code Here
   1: import java.io.DataInputStream;
   2: import java.io.DataOutputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     public final void dump( DataOutputStream file ) throws IOException {
   7:         file.writeByte(tag);
   8:         ...
   9:         file.writeFloat(bytes);
  10:     }

View Full Code Here
   1: import java.io.DataInputStream;
   2: import java.io.DataOutputStream;
   3: import javax.jms.Connection;
   4:         ...
   5:     protected Connection consumerConnection;
   6:     protected DataOutputStream out;
   7:     protected DataInputStream in;
   8:         ...
   9:         consumerConnection.start();
  10:         out = new DataOutputStream(new JMSOutputStream(producer));
  11:         in = new DataInputStream(new JMSInputStream(consumer));
  12:         ...
  13:         assertTrue(in.readInt() == 4);
  14:         out.writeFloat(2.3f);

View Full Code Here

writeInt

public final void writeInt(int v)
            throws IOException
Writes an int to the underlying output stream as four bytes, high byte first. If no exception is thrown, the counter written is incremented by 4.
Specified by:
writeInt in interface DataOutput
Parameters:
v - an int to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeInt(int v)
   1: 
   2:     public void pickle(DataOutputStream out, Object i) 
   3:     throws IOException
   4:         ...
   5:     {
   6:     out.writeInt(((Integer) i).intValue()) ;
   7:     }
   8: 

View Full Code Here
   1: 
   2:     public static void outputObject(Object obj, DataOutputStream out) throws IOException {
   3:         if (obj instanceof XMLRootObject) {
   4:         ...
   5:             out.writeInt(XMLRootObjectType);
   6: 
   7:         ...
   8:         } else if (obj instanceof byte[]) {
   9:             out.writeInt(ByteArrayType);
  10:         ...
  11:             out.writeInt(((byte[]) obj).length);

View Full Code Here
   1: 
   2: import java.io.DataOutputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     public void save(ResourceInfo info, IPathRequestor requestor, DataOutputStream output, List writtenTypes) throws IOException {
   7:         if (info.isSet(ICoreConstants.M_PHANTOM))
   8:         ...
   9:         if (output.size() == 0)
  10:             output.writeInt(MARKERS_SAVE_VERSION);
  11:         boolean[] isPersistent = (boolean[]) result[1];
  12:         ...
  13:         output.writeUTF(requestor.requestPath().toString());
  14:         output.writeInt(count);

View Full Code Here
   1: import java.io.DataOutput;
   2: import java.io.DataOutputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     static  public void marshalPrimitiveMap(HashMap map, DataOutputStream out) throws IOException {
   7:         if( map == null ) {
   8:         ...
   9:             out.writeInt(-1);
  10:         } else {
  11:         ...
  12:             out.writeInt(map.size());

View Full Code Here
   1: 
   2: import java.io.DataOutputStream;
   3: import java.io.IOException;
   4:         ...
   5: {
   6:   public static void writeUntaggedValue(DataOutputStream os, Object obj)
   7:     throws JdwpException, IOException
   8:         ...
   9:   
  10:   public static void writeTaggedValue(DataOutputStream os, Object obj)
  11:     throws JdwpException, IOException
  12:         ...
  13:               os.writeByte(JdwpConstants.Tag.BYTE);
  14:             os.writeInt(((Integer) obj).intValue());

View Full Code Here

writeLong

public final void writeLong(long v)
            throws IOException
Writes a long to the underlying output stream as eight bytes, high byte first. In no exception is thrown, the counter written is incremented by 8.
Specified by:
writeLong in interface DataOutput
Parameters:
v - a long to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeLong(long v)
   1: 
   2:     public void pickle(DataOutputStream out, Object l) 
   3:     throws IOException
   4:         ...
   5:     {
   6:     out.writeLong(((Long) l).longValue()) ;
   7:     }
   8: 

View Full Code Here
   1: 
   2: import java.io.DataOutputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:   public void write(DataOutputStream os) 
   7:     throws IOException
   8:         ...
   9:         method.writeId(os);
  10:         os.writeLong(index);
  11:       }
  12:         ...
  13:         os.writeByte(1);
  14:         os.writeLong((long) 0);

View Full Code Here
   1: import java.io.ByteArrayOutputStream;
   2: import java.io.DataOutputStream;
   3: import java.io.IOException;
   4:         ...
   5:         ByteArrayOutputStream baos = new ByteArrayOutputStream();
   6:         DataOutputStream os = new DataOutputStream(baos);
   7:         ...
   8:         os.writeLong(++txGenerator);
   9:         os.close();

View Full Code Here
   1: import java.io.ByteArrayOutputStream;
   2: import java.io.DataOutputStream;
   3: import java.io.IOException;
   4:         ...
   5:         ByteArrayOutputStream baos = new ByteArrayOutputStream();
   6:         DataOutputStream os = new DataOutputStream(baos);
   7:         ...
   8:         os.writeLong(++txGenerator);
   9:         os.close();

View Full Code Here
   1: import java.io.DataOutput;
   2: import java.io.DataOutputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     static  public void marshalPrimitiveMap(HashMap map, DataOutputStream out) throws IOException {
   7:         if( map == null ) {
   8:         ...
   9: 
  10:     static public void marshalPrimitive(DataOutputStream out, Object value) throws IOException {
  11:         if( value == null ) {
  12:         ...
  13:             out.writeByte(LONG_TYPE);
  14:             out.writeLong(((Long)value).longValue());

View Full Code Here

writeShort

public final void writeShort(int v)
            throws IOException
Writes a short to the underlying output stream as two bytes, high byte first. If no exception is thrown, the counter written is incremented by 2.
Specified by:
writeShort in interface DataOutput
Parameters:
v - a short to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeShort(int v)
   1: 
   2:   void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
   3:     throws IOException, jasError
   4:         ...
   5:   {
   6:     out.writeShort(e.getCPIndex(attr));
   7:     out.writeInt(2 + 4*(pc.size()));
   8:         ...
   9:     out.writeShort(pc.size());
  10:     for (Enumeration en = pc.elements(), ien = line.elements();
  11:         ...
  12:     l.writeOffset(ce, null, out);
  13:     out.writeShort((int) i.intValue());

View Full Code Here
   1: 
   2:     public void write(DataOutputStream out) throws IOException {
   3:         ...
   4:     out.writeShort(nameIndex);
   5:     out.writeInt(length);
   6:         ...
   7:     out.writeShort(exceptionIndexTable.size());
   8:     Iterator it = exceptionIndexTable.iterator();
   9:         ...
  10:     while (it.hasNext()) {
  11:         out.writeShort(((Short)it.next()).shortValue());

View Full Code Here
   1: 
   2:     public void write(DataOutputStream out) throws IOException {
   3:     out.writeInt(MAGIC);
   4:         ...
   5:     out.writeShort(MINOR_VERSION);
   6:         ...
   7:     out.writeShort(MAJOR_VERSION);
   8: 
   9:         ...
  10: 
  11:     out.writeShort(accessFlags);

View Full Code Here
   1: 
   2:     public void writeWordInventory (DataOutputStream to) throws IOException {
   3:     int i, j;
   4:         ...
   5: 
   6:     to.writeShort(this.docId);
   7:         ...
   8:     to.writeShort(this.count);
   9:         ...
  10:     to.writeShort(this.weight);

View Full Code Here
   1: import java.io.DataOutput;
   2: import java.io.DataOutputStream;
   3: import java.io.IOException;
   4:         ...
   5: 
   6:     static  public void marshalPrimitiveMap(HashMap map, DataOutputStream out) throws IOException {
   7:         if( map == null ) {
   8:         ...
   9: 
  10:     static public void marshalPrimitive(DataOutputStream out, Object value) throws IOException {
  11:         if( value == null ) {
  12:         ...
  13:             out.writeByte(SHORT_TYPE);
  14:             out.writeShort(((Short)value).shortValue());

View Full Code Here

writeUTF

public final void writeUTF(String str)
            throws IOException
Writes a string to the underlying output stream using modified UTF-8 encoding in a machine-independent manner.

First, two bytes are written to the output stream as if by the writeShort method giving the number of bytes to follow. This value is the number of bytes actually written out, not the length of the string. Following the length, each character of the string is output, in sequence, using the modified UTF-8 encoding for the character. If no exception is thrown, the counter written is incremented by the total number of bytes written to the output stream. This will be at least two plus the length of str, and at most two plus thrice the length of str.

Specified by:
writeUTF in interface DataOutput
Parameters:
str - a string to be written.
Throws:
IOException - if an I/O error occurs.
Usages and Demos :

View More Examples of writeUTF(String str)
   1: import java.util.Vector;
   2: import java.io.DataOutputStream;
   3: import java.io.BufferedOutputStream;
   4:         ...
   5:     String table, fileName;
   6:     DataOutputStream streamOut;
   7:     for(int i = 0;;)
   8:         ...
   9:         fileName = abd.chemin + table + ".dat";
  10:         streamOut = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(fileName)));
  11: 
  12:         ...
  13:       {
  14:     streamOut.writeUTF("@GEAMAS_DATA(~LP01)");

View Full Code Here
   1: 
   2: import java.io.DataOutputStream;
   3: import java.io.BufferedOutputStream;
   4:         ...
   5:     String table, fileName;
   6:     DataOutputStream streamOut;
   7:     for(int i = 0;;)
   8:         ...
   9:         fileName = "biomas/base/datafiles/" + table + ".dat";
  10:         streamOut = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(fileName)));
  11:         rs = stmt.executeQuery ("SELECT * FROM " + table);
  12:         ...
  13:       {
  14:     streamOut.writeUTF("@BIOMAS_DATA(~AFH99)");

View Full Code Here
   1: import java.io.DataInputStream;
   2: import java.io.DataOutputStream;
   3: import java.io.EOFException;
   4:         ...
   5:         ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
   6:         DataOutputStream dataOut = new DataOutputStream(byteOut);
   7:         ServiceID sid = new ServiceID(42l, 42l);
   8:         ...
   9:         dataOut.writeInt(1);
  10:         dataOut.writeUTF(InetAddress.getLocalHost().getHostAddress());
  11:         dataOut.writeInt(st.getServerSocketPort());
  12:         ...
  13:         dataOut.writeInt(1);
  14:         dataOut.writeUTF("");

View Full Code Here
   1: import java.io.ByteArrayOutputStream;
   2: import java.io.DataOutputStream;
   3: import java.util.Arrays;
   4:         ...
   5:             ByteArrayOutputStream bout = new ByteArrayOutputStream();
   6:             DataOutputStream out = new DataOutputStream(bout);
   7: 
   8:         ...
   9:             String className = classInfo.getName();
  10:             out.writeUTF(className);
  11: 
  12:         ...
  13:                 for (int i = 0; i < interfaces.length; i++) {
  14:                     out.writeUTF(interfaceNames[i]);

View Full Code Here
   1:         ByteArrayOutputStream out = new ByteArrayOutputStream();
   2:         DataOutputStream dos = new DataOutputStream(out);
   3:         try {
   4:         ...
   5:             dos.writeUTF(getRoot());
   6:         ...
   7:             dos.writeUTF(getRepository());
   8:             CVSEntryLineTag t = getTag();
   9:         ...
  10:             } else {
  11:                 dos.writeUTF(t.toString());

View Full Code Here