이 코드를 실행하려고하는데 유효한 인수를 제공하고 있지만 여전히 줄 번호가 잘못 표시됩니다. 34 및 35에서 지역 변수 fin 및 fout이 초기화되지 않았을 수 있습니다. 이 enter code here
try 블록 안에 FileIStream 변수가 초기화되지 않았을 수 있습니다. 오류
package maxbj.myTest.p1;
import java.io.*;
public class CopyFile {
public static void main(String[] args)throws IOException {
int i;
FileInputStream fin;
FileOutputStream fout;
try{
//trying to open input file
try{
fin=new FileInputStream(args[0]);
}catch(FileNotFoundException e){
System.out.println("Input file not found");
return;
}
//trying to open output file
try{
fout=new FileOutputStream(args[1]);
return;
}catch(FileNotFoundException e){
System.out.println("Output file cannot be opened or created");
return;
}
}catch(ArrayIndexOutOfBoundsException e){
System.out.println("Array index out of bound exception");
}
//code to copy file
try{
do{
i=fin.read();
if(i!=-1) fout.write(i);
}while(i!=-1);
}catch(IOException e){
System.out.println("File Error");
}
fin.close();
fout.close();
}
}
이 코드는 책이다 PS- "JAVA COMPLETE에 refrence"를 해결하는 방법
@SotiriosDelimanolis 해결 방법이 아니며 해결 방법 일뿐입니다. 픽스는 'fin'이 초기화되지 않은 경로가 없음을 확인합니다. 상대적으로 간단한 일입니다. – dasblinkenlight