티스토리 뷰

 

 

Beginning Java Networking

Chad Darby, www.wrox.com



// DataInputTest.java

import java.io.DataInputStream; import java.io.FileInputStream;
import java.io.IOException;

public class DataInputTest {

  public DataInputTest() {
  }

  public static void main(String args[]) {
    FileInputStream fileIn = null;
    DataInputStream dataIn = null;

    try {
      fileIn = new FileInputStream("datatest.txt");
      dataIn = new DataInputStream(fileIn);

      /*
       * We read in the following record consisting of:
       * boolean:
       * int:
       * float:
       * long:
       * double:
       */

      System.out.println("boolean:" + dataIn.readBoolean());
      System.out.println("int:    " + dataIn.readInt());
      System.out.println("float:  " + dataIn.readFloat());
      System.out.println("long:   " + dataIn.readLong());
      System.out.println("double: " + dataIn.readDouble());

      dataIn.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
글 보관함