Why am I getting java.lang.ArrayIndexOutOfBoundsException :0 at CopyFile.main
//Copy one file Data to another File
import java.io.*;
class CopyFile{
public static void main(String[] args)throws IOException{
FileInputStream fis=new FileInputStream(args[0]);//reading File
FileOutputStream fos=new FileOutputStream(args[1]);//reading File
int data;
while((data=fis.read())!=-1){
fos.write(data);
/*here using while loop to copy data from one file and storing it in another file*/
}
}
}
It seems you are running the file as
If you do so, its wrong. You should pass the arguments to run your code since your are looking for two arguments.
Run the code this way:-