0% found this document useful (0 votes)
30 views7 pages

File I/O & Collection Framework

The document discusses file input/output and collections in Java. It describes the role of files as persistent storage for shared information. The Java File class represents files and directories in an abstract way and is used for creating, searching, deleting files and more. A File object provides information about a disk file like permissions, time, and path to navigate directory hierarchies. Streams are sequences of data like bytes and are used for input/output attached to the console like System.out for standard output.

Uploaded by

Aditya Chavan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views7 pages

File I/O & Collection Framework

The document discusses file input/output and collections in Java. It describes the role of files as persistent storage for shared information. The Java File class represents files and directories in an abstract way and is used for creating, searching, deleting files and more. A File object provides information about a disk file like permissions, time, and path to navigate directory hierarchies. Streams are sequences of data like bytes and are used for input/output attached to the console like System.out for standard output.

Uploaded by

Aditya Chavan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 7

File I/O & Collection

Framework
[12]
What is the role of file in java? [4M]
persistent
Files are still a central resource for storing
and shared information.
pathnames
Java File class represents the files and directory
in an abstract manner.
directories,
File class is used for creation of files and
file searching, file deletion, etc.
retrieved
File class does
from or not specify
stored in howit information
files; describes is
the
properties of a file itself.
theA information
File object is used to obtain or manipulate
associated with a disk file, such
as the permissions, time, date, and directory
path, and to navigate subdirectory hierarchies.
 There
appletsare severe reasons.
restrictions on their use within
for security
File [4M]
File objects:
 File(String directoryPath)
 File(String directoryPath, String filename)
 File(File obj, String filename)
 Here, directoryPath
filename is the name isof
the path
the file, name
and of is
obj thea file,
File
object that specifies a directory.
File Class [4M]
public String getName()
 public String getPath()
 public String getAbsolutePath()
 public boolean canRead()
 public boolean canWrite()
 public boolean exists()
 public boolean isDirectory()
 public boolean isFile()
 public boolean createNewFile()
 public long length()
 public boolean delete()
 public String[] list()
 public boolean mkdir()
 public boolean setReadOnly()
Stream [2M]
stream
A stream
is is a sequence
composed of bytes. of data.
It's Ina Java
called a
stream
because it's like a stream of water that continues
to flow.


are attached with console.
1) System.out: standard output stream
2) System.in: standard input stream
 3) System.err: standard error stream

You might also like