Saturday, 26 April 2014

Ex 30: Write a program in Java, which takes the name of a file from user, read the contents of the file and display it on the console.

import java.io.*;
class s08_05
{
public static void main(String args[])
{
FileInputStream fis=null;
Try
{
fis=new FileInputStream(args[0]);
byte ch;
while((ch=(byte)fis.read())!=-1)
{System.out.print((char)ch); }
}
catch(IOException e)
{ System.out.println("interrupted");}
finally
{
try
{fis.close();}
catch(IOException e)
{System.out.println("error in closing");}
}
}
}

1 comment:

  1. Your Affiliate Profit Machine is ready -

    Plus, making money online using it is as easy as 1 . 2 . 3!

    Here are the steps to make it work...

    STEP 1. Choose which affiliate products the system will promote
    STEP 2. Add PUSH BUTTON TRAFFIC (it takes JUST 2 minutes)
    STEP 3. See how the system grow your list and up-sell your affiliate products for you!

    So, do you want to start making money??

    Your MONEY MAKING affiliate solution is RIGHT HERE

    ReplyDelete