Fileinfo - Java: S.No: 18 Date: 2022-06-15
Fileinfo - Java: S.No: 18 Date: 2022-06-15
Name: Write a Java program that reads a file name from the user then displays
S.No: 18 Date: 2022-06-15
ID: 20095A0363
Page No:
information
Aim:
Write a Java program that reads a file name from the user then displays information about whether the file
exists, whether the file is readable, whether the file is writable, the type of file and the length of the file in bytes.
Source Code:
FileInfo.java
import java.io.*;
class FileInfo
String fname=br.readLine();
text1.txt
We know that we cannot save our environment overnight. But, having an intention
to make
possible is all that count. Reduce wastage of papers. Try not to ruin plants. Th
ey
are one of the biggest factors that can keep the earth fertile and save the lif
e. Save
trees to save our environment. Encourage your child to plant trees in any empty
ground.
As I said before, the initiative counts. If you feel the need of saving the envi
ronment,
you will stop others from doing something which can hurt the well being of the n
ature.
text2.txt
Your every action will count. You should not only hold others responsible, make
yourself responsible too.
Why not start saving our environment being a little less self-concerned. Sometim
es give priority to the
nature before giving priority to yourself. Save the energy, save plants and be s
ympathetic to the nature
surrounding us.
ID: 20095A0363
Page No:
Execution Results - All test cases have succeeded!
Test Case - 1
User Output
Enter file name(text1.txt or text2.txt): text.txt
File existance: false
File writable: false
File readable: false
File length(in bytes): 0 Bytes
Test Case - 2
User Output
Enter file name(text1.txt or text2.txt): text1.txt
File existance: true
File writable: true
File readable: true
File length(in bytes): 521 Bytes