자바 질문이요!!!
연블루
copy메소드에서 사용하는 2개의 인수를 파일 입출력하는 스트림으로 바꾸고, 첫번째 인수가 가리키는 파일의 내용을 두번째 인수가 가리키는 파일로 복사하는 프로그램을 고치라는데..(전 여기까지 밖에 못해서 어떻게 해야하는 지 잘모르 겠어요)
import java .io.*;
public class lim
{
static FileOutputStream fout;
static FileInputStream fin;
public static void main(String args[]){
if(args.length!=1)
{
System.err.println(파일이름을 지정하여 주십시오);
}
try{
fout=new FileOutputStream(args[0]);
fin= new FileInputStream(args[1]);copy(fin,fout);
}
catch(IOException e)
{ System.err.print(스트림으로부터 데이터를 읽을수 없을 수 있습니다.);
}finally{
try{if(fin!=null)fin.close();
if(fout!=null)fout.close();
}catch(IOException e){}
}
}
public static void copy(InputStream in,OutputStream out)throws IOException{
int bytesRead;
byte[]buffer=new byte[256];
synchronized(in){
while((bytesRead=in.read(buffer))=0)
{
fout.write(buffer,0,bytesRead);
}
synchronized(out){
while((bytesRead=System.in.read(buffer))=0)
{
System.out.write(buffer,0,bytesRead);
}
}
}
}
}