why this code does not execute

//java CopyFile aage.txt boxdemo.txt
import java.io.*;
class copyfile
{
public static void main(String args[])throws IOException
{
int i;
FileInputStream fin;
FileOutputStream fout;
try
{
fin=new FileInputStream(args[0]);
}
catch(FileNotFoundException e)
{
System.out.println("Input file not found");
return;
}
//open output file
try
{
fout=new FileOutputStream(args[1]);
}
catch(FileNotFoundException e)
{
System.out.println("Erroe opening output file");
return;
}
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("Usage:copyfile from to");
return;
}
//copy file
try
{
do
{
i=fin.read();
if(i!=-1)
fout.write(i);
}
while(i!=-1);
}
catch(IOException e)
{
System.out.println("file error");
}
fis.close();
fout.close();
}
}

Replies

  • Manish Goyal
    Manish Goyal
    There are two errors in your program .In order to remove these errors

    1:-Reconstruct your program with proper indentation.

    2:-There is a very silly error in this program .


    check your program again ,you will find it
  • anandkumarjha
    anandkumarjha
    Hello CEans
    can anyone explain me the use of volatile modifier in java programming???
  • The_Small_k
    The_Small_k
    Try this one
    //java CopyFile aage.txt boxdemo.txt
    import java.io.*;
    class copyfile
    {
        
        public static void main(String args[])throws IOException
        {
            int i;
            FileInputStream fin=null;
            FileOutputStream fout=null;
            try
            {
                fin=new FileInputStream(args[0]);
            }
            catch(FileNotFoundException e)
            {
                System.out.println("Input file not found");
            return;
            }
            //open output file
            try
            {
                fout=new FileOutputStream(args[1]);
            }
            catch(FileNotFoundException e)
            {
                System.out.println("Erroe opening output file");
                return;
            }
            catch(ArrayIndexOutOfBoundsException e)
            {
                System.out.println("Usage:copyfile from to");
                return;
            }
            //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();
        }
    }
    

You are reading an archived discussion.

Related Posts

Hi, Currently i am using Proteus 7.4SP3 to simulate the AD633 multiplier. The two input is a trend of pulses and i want to get the output. The problem is...
Continuing its electric car research, Mercedes-Benz has begun series production of 500 E-Cell electric cars. The new E-Cell uses the Mercedes-Benz A-class platform, with an electric power train provided by...
BlackBerry smart phone creators have granted India's government with manual access to its Messenger service and has promised automated access by 1st of January thereby enabling authorities to track such...
Verizon offering money for used phones Here's how it works: You check Verizon's trade-in site, and do an online appraisal of the phone. You give the phone's make, model and...
Raytheon Engineers unveiled its second generation Exoskeleton or XOS2 robotic suit this week. The suit gives the wearer superhuman strength and this latest version is lighter, faster and stronger than...