Your SlideShare is downloading. ×
Class data outputstream
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Class data outputstream

143
views

Published on

Published in: Education, Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
143
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Class DataOutputStream DataOutputStream
  • 2. DataOutputStream • 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. DataOutputStream
  • 3. java.io.DataOutputStream public class DataOutputStream extends OutputStream implements DataOutput DataOutputStream
  • 4. DataOutputStream constructor • DataOutputStream(OutputStream out) • Creates a new data output stream to write data to the specified underlying output stream. DataOutputStream
  • 5. writeUTF() • Writes a string to the underlying output stream using UTF-8 encoding in a machineindependent manner. DataOutputStream
  • 6. writeUTF() • public final void writeUTF(String str) throws IOException • 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 UTF-8 encoding for the character. DataOutputStream
  • 7. writeBoolean() • 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. DataOutputStream
  • 8. writeBoolean() syntax public final void writeBoolean(boolean v) throws IOException DataOutputStream
  • 9. writeInt() • Writes an int to the underlying output stream as four bytes, high byte first • public final void writeInt(int v) throws IOException DataOutputStream
  • 10. Flush() • 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. • public void flush() throws IOException DataOutputStream
  • 11. Close() • Closes this output stream and releases any system resources associated with the stream.The close method calls its flush method, and then calls the close method of its underlying output stream. • public void close() throws IOException DataOutputStream