| [ WWW ] in KIDS 글 쓴 이(By): bsjung (정병수) 날 짜 (Date): 1995년12월24일(일) 18시13분23초 KST 제 목(Title): copy2.java +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * copy2.java * by bsjung@galaxy.postech.ac.kr +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 이 프로그램은 앞의 copy.java를 개량한 것으로써 프로그램상에 화일명이 고정된것을 입력할수 있도록 한것입니다. 컴파일은 % javac copy2.java 실행은 % java copy2 input.dat output.dat (여기서 input.dat 와 output.dat 가 고정된것은 아님.) 결과는 input.dat 가 output.dat 로 copy 됩니다. 그리고 input.dat 가 준비되어야 되겠내요. --------------------< cut here >------------------- /* * @(#)copy2.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 copy2 { String args[]; public static void main (String args[]){ String s = "this is a test for copy2"; String s2 = "Usage: java copy2 inputfile outputfile"; FileInputStream fin = null; FileOutputStream fout = null; fin = new FileInputStream(args[0]); fout = new FileOutputStream(args[1]); System.out.println(s); System.out.println(s2); System.out.println("input file : " + args[0]); System.out.println("output file : " + args[1]); int a; while ((a = fin.read())!=-1) fout.write(a); fin.close(); fout.close(); } } --------------------< cut here >------------------- |