← Back to feed
Renewal·서른의 생활코딩

Ex15) Java I/O - DataOutputStream + DataInputStream

NS
normalstory
cover image


import java.io.*;

public class DataIOTest {
public static void main( String[] args ) {
try {
// file에 저장하기 위한 FileOutputStream object creation
FileOutputStream fos = new FileOutputStream( "data.txt" );
//output,bufferX,여기선 write function 밖에 없다.
// FileOutputStream object를 argument로 받아 들이는
// DataOutputStream object creation
DataOutputStream dos = new DataOutputStream( fos );
//다양한  write function지원!!!! (output전용)
// 각 데이타 타이에 맞는 write method를 call해
// file에 데이타를 저장
dos.writeChar( 'j' );
dos.writeInt( 1234 );
dos.writeBoolean( true ); //4byte 
dos.writeFloat( 3.14F );
dos.writeDouble( 123.5423 );
dos.writeUTF( "gemini" );
//outputfunction=내용을 모두 읽어서 ,단위별로 끊어서!
// file에서 데이타를 읽어 들이기 위한
// FileInputStream object creation
FileInputStream fis = new FileInputStream( "data.txt" );
//(input전용)+다양한 readfunction 사용possible ,단 닫고나서 읽는것이 표준!!
//+ 단 output과 같은 순서로  작성되어야한다.!
// 각데이타 type별로 데이타를 읽어 들이기 위한
// DataInputStream object creation
DataInputStream dis = new DataInputStream( fis );
// 각 데이타 type에 맞게 read()를 call해
// file에서 데이타를 읽어 들임
System.out.println( dis.readChar() );
System.out.println( dis.readInt() );
System.out.println( dis.readBoolean() );
System.out.println( dis.readFloat() );
System.out.println( dis.readDouble() );
System.out.println( dis.readUTF() );
// file과의 stream 해제, 자원 반납
dos.close();
dis.close();
} catch ( IOException io ) {
System.out.println( io.toString() );
}
}
}
  • Open in Google Docs Viewer
  • Open link in new tab
  • Open link in new window
  • Open link in new incognito window
  • Download file
  • Copy link address
  • Edit PDF File on PDFescape.com
  • Open in Google Docs Viewer
  • Open link in new tab
  • Open link in new window
  • Open link in new incognito window
  • Download file
  • Copy link address
  • Edit PDF File on PDFescape.com

element

Font
font-family
font-size
font-style
font-variant
font-weight
letter-spacing
line-height
text-decoration
text-align
text-indent
text-transform
white-space
word-spacing
color
Background
bg-attachment
bg-color
bg-image
bg-position
bg-repeat
Box
width
height
border-top
border-right
border-bottom
border-left
margin
padding
max-height
min-height
max-width
min-width
outline-color
outline-style
outline-width
Positioning
position
top
bottom
right
left
float
display
clear
z-index
List
list-style-image
list-style-type
list-style-position
Table
vertical-align
border-collapse
border-spacing
caption-side
empty-cells
table-layout
Effects
text-shadow
-webkit-box-shadow
border-radius
Other
overflow
cursor
visibility

element

Font
font-family
font-size
font-style
font-variant
font-weight
letter-spacing
line-height
text-decoration
text-align
text-indent
text-transform
white-space
word-spacing
color
Background
bg-attachment
bg-color
bg-image
bg-position
bg-repeat
Box
width
height
border-top
border-right
border-bottom
border-left
margin
padding
max-height
min-height
max-width
min-width
outline-color
outline-style
outline-width
Positioning
position
top
bottom
right
left
float
display
clear
z-index
List
list-style-image
list-style-type
list-style-position
Table
vertical-align
border-collapse
border-spacing
caption-side
empty-cells
table-layout
Effects
text-shadow
-webkit-box-shadow
border-radius
Other
overflow
cursor
visibility

This English version was translated by Claude.

친절한 찰쓰씨
Written by
친절한 찰쓰씨

Pleasant Charles — UI/UX researcher at AIT. Keeping notes on design, planning, and slow days here since 2010.