Java program demonstrating the usage of FileInputStream in package-Different Way

The FileInputStream class creates an InputStream that you can use to read bytes from a file.

For this you need to create a text file called Hello.txt with some text. We will read from this file and display it in console.

//Java Program demonstrating the FileInputStream Class in package

Check out the while loop used for looping the File


class FileInputStreamDemo1
	public static void main(String[] args)
			File f = new File("Hello.txt");
			int size;
			FileInputStream fis = new FileInputStream(f);
			System.out.println("Total Available Bytes: " + (size = fis.available()));

			int i = 0;
				i =;
		catch(Exception e)

Snapshot of the o/p- Same as this program         


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s