java - Why am I getting an ArrayIndexOutOfBoundsException in my code? -


why getting java.lang.arrayindexoutofboundsexception :0 @ copyfile.main

//copy 1 file data 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 copy data 1 file , storing in file*/             }         } } 

it seems running file as

java copyfile 

if so, wrong. should pass arguments run code since looking 2 arguments.

run code way:-

java copyfile arg1 arg2 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -