예제 10-11
2013-02-27
|
by stvking
1570
import java.io.*;
class FileDump {
public static void main(String args[]) {
if (args.length < 1) {
System.out.println("Usage: java FileDump ");
return;
}
BufferedInputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(args[0]));
byte arr[] = new byte[16];
while(true) {
int num = in.read(arr);
if (num < 0)
break;
for (int cnt=0; cnt
System.out.printf("%02X ", arr[cnt]);
System.out.println();
}
}
catch (FileNotFoundException fnfe) {
System.out.println(args[0] + "파일이 존재하지 않습니다.");
}
catch (IOException ioe) {
System.out.println(args[0] + "파일을 읽을 수 없습니다.");
}
finally {
try {
in.close();
}
catch (Exception e) {
}
}
}
}
위는 예제10-11 입니다.
이해 안 가는 행이 몇 행 있는데,
if (args.length < 1) { ,
in = new BufferedInputStream(new FileInputStream(args[0])); ,
System.out.printf("%02X ", arr[cnt]); ,
이 행 세개를 이해 못하겠습니다.
어떠한 기능을 하며, 이렇게 작성한 의도가 무엇인지 알고싶습니다.
그리고
in = new BufferedInputStream(new FileInputStream(args[0])); <- 행에서 "args[0]"가 아닌 args[0]인 이유는 무엇인가요? 즉, 큰따음표가 없는 이유는 무엇인가요?