티스토리 뷰

 

 

Beginning Java Networking

Chad Darby, www.wrox.com


필터링 클래스 - 스트림의 기본 성능을 확장하여 들어오거나 나가는 양쪽 모두의 스트림에게 의미를 부여한다.


// DataOutputTest.java

import java.io.DataOutputStream; import java.io.FileOutputStream;
import java.io.IOException;

public class DataOutputTest {

  public DataOutputTest() {
  }

  public static void main(String args[]) {
    FileOutputStream fileOut = null;
    DataOutputStream dataOut = null;

    try {
      fileOut = new FileOutputStream("datatest.txt");
      dataOut = new DataOutputStream(fileOut);

      /*
       * We write out the following record consisting of:
       * boolean: true
       * int:     98765
       * float:   1.5f
       * long:    3210L
       * double:  25.65d
       */

      dataOut.writeBoolean(true);
      dataOut.writeInt(98765);
      dataOut.writeFloat(1.5f);
      dataOut.writeLong(3210L);
      dataOut.writeDouble(25.65d);
      dataOut.flush();

      dataOut.close();
    }
    catch (IOException ioe) {
      ioe.printStackTrace();
    }
  }
}



댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함