[例] 引数1→引数2のファイル間のコピーを行うダウンロード CpSample.java
< CpSample.java >
import java.io.*; public class CpSample { public static void main( String argv[] ) { FileInputStream fis; FileOutputStream fos; try { fis = new FileInputStream( argv[0] ); fos = new FileOutputStream( argv[1] ); int b; while( ( b = fis.read() ) != -1 ) { fos.write( (byte)b ); } fis.close(); fos.close(); } catch( Exception e ) { System.err.println("Error...."); System.exit(-1); } } }
2003年10月6日 12:19 更新