//wap to take a file name from user and print total bytes of file
PROGRAM CODE---
import java.util.*;
import java.io.*;
class TakeFile
{
public static void main(String a[]) throws Exception
{
Console c = System.console();
System.out.println("enter file name");
String s = c.readLine();
InputStream i;
int total=0;
int l = s.length();
if(l == 0)
{
i = System.in;
}
else
{
i = new FileInputStream(s);
while((i.read())!=-1)
{
total++;
}
}
System.out.println("size of given file is"+ total);
}
}



Comments
Post a Comment