WWW

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


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

이 프로그램은 자바 API 의 FileInputStream 과 FileOutputStream을 이용한
것입니다. 처음 버전은 프로그램상에서 입력 데이타 화일과 출력 데이타 화일을
고정시킨 기본적인 것입니다.

컴파일은 % javac copy.java
실행은   % java copy

결과는 input.dat 가 output.dat 로 copy 됩니다.
아참 input.dat 가 준비되어야 되겠내요.

--------------------< cut here >-------------------
/*
 * @(#)copy.java  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 시킵니다.
// C나 C++에서는 #include 를 하지만
// 자바에서는 import를 시킨다고 하지요.
import java.lang.*;             // 기본적인것들이 정의되어있는 클래스이지요
import java.io.FileInputStream; // 입력 데이타를 위해서이지요
import java.io.FileOutputStream; // 출력 데이타를 위해서이지요

// 클래스를 선언한다
class copy {
    // 클새스의 method 중 Application에 꼭 있어야 하는 method 이지요.
    public static void main (String args[]){
    // 여기에서 main 다음에 String 인것을 주의하세요.
        String s = "this is a test for copy";
        String s2 = "input file name : input.dat";
        String s3 = "output file name : output.dat";

        FileInputStream fin = null;
        FileOutputStream fout = null;
        // 입력 데이타와 출력 데이타를 준비합니다.
        fin = new FileInputStream("input.dat");
        fout = new FileOutputStream("output.dat");
        System.out.println(s);
        System.out.println(s2);
        System.out.println(s3);
        int a;
        // 한 byte 씩 읽고 씁니다.
        while ((a = fin.read())!=-1) // read()는 EOF일때 -l을 반납합니다.
            fout.write(a);
       // 화일을 닫습니다.
        fin.close();
        fout.close();
    }
}
--------------------< cut here >-------------------
[알림판목록 I] [알림판목록 II] [글 목록][이 전][다 음]
키 즈 는 열 린 사 람 들 의 모 임 입 니 다.