WWW

[알림판목록 I] [알림판목록 II] [글목록][이 전][다 음]
[ WWW ] in KIDS
글 쓴 이(By): bsjung (정병수)
날 짜 (Date): 1995년12월24일(일) 18시14분24초 KST
제 목(Title): copy3.java


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                * copy3.java *
        by bsjung@galaxy.postech.ac.kr
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

이 프로그램은 앞의 copy2.java를 더 개량한 것으로서 try and catch를
이용한 에러 체크를 포함한 것입니다.

컴파일은 % javac copy3.java
실행은   % java copy3 input.dat output.dat

결과는 input.dat 가 output.dat 로 copy 됩니다.
그리고 input.dat 가 준비되어야 되겠내요.
준비되어 있지 않으면 다음과 같은 Usage 가 출력됩니다.

    Usage: java copy3 inputfile outputfile


--------------------< cut here >-------------------

/*
 * @(#)copy3.java 1.181 95/12/24 Jung Byung Soo
 * Copyleft (c) 1995 Postech, All Rights Free.
 *
 * Permission to use, copy, modify, and distribute this software
 * and its documentatin for COMMERCIAL purpose and without
 * fee is hereby granted provided.
 *
 * BSJUNG MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 */
import java.lang.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;

class copy3 {
    String args[];
    public static void main (String args[]){
        String s = "this is a test for copy2";
        String s2 = "Usage: java copy3 inputfile outputfile";

        FileInputStream fin = null;
        FileOutputStream fout = null;
        try {
            fin = new FileInputStream(args[0]);
            fout = new FileOutputStream(args[1]);
        System.out.println(s);
        System.out.println("input file : " + args[0]);
        System.out.println("output file : " + args[1]);

        int a;
        while ((a = fin.read())!=-1)
            fout.write(a);
        } catch(Exception e) {
            System.out.println("");
            System.out.println(s2);
            System.out.println("");
        }
        fin.close();
        fout.close();
    }
}
--------------------< cut here >-------------------
[알림판목록 I] [알림판목록 II] [글 목록][이 전][다 음]
키 즈 는 열 린 사 람 들 의 모 임 입 니 다.