Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
30 views

File Input and Output

The document discusses file input and output (I/O) in three paragraphs. It explains that file organization involves parts separated by blank lines, buffers store streams of data from devices, and I/O moves data into and out of buffers. The second paragraph notes code will read and write to the user's home directory. The third paragraph states random access files function like arrays of bytes and the file pointer acts as a cursor.

Uploaded by

Mark Ven Lambot
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

File Input and Output

The document discusses file input and output (I/O) in three paragraphs. It explains that file organization involves parts separated by blank lines, buffers store streams of data from devices, and I/O moves data into and out of buffers. The second paragraph notes code will read and write to the user's home directory. The third paragraph states random access files function like arrays of bytes and the file pointer acts as a cursor.

Uploaded by

Mark Ven Lambot
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Name: Mark Ven Lambot Date: May 20, 2021

Year and Section: BSIS 2-D Contact Number: 09109701217

File Input and Output


1.) File Organization is a file that is made up of parts separated by blank lines and an optional
statement that identifies each one. A buffer is a memory area dedicated to storing a stream of data
from peripheral devices. The stream of data is then processed and stored in variables from this
buffer. A continuous flow of data is referred to as a stream. Moving data into and out of buffers is
what the expression "input/output" refers to. Simply keep this in mind at all times. I/O is
requested by processes. To put it another way, imagine typing data into a keyboard. The data
travels through a pipe (the stream) to the buffer, and then from the buffer to the disk (write
operation). It's also a read process as data travels from disk to buffer and then from buffer to
monitor.

2.) The example code will read and write from a file in the user's home directory to prevent any
misunderstanding about the file route. System.getProperty("user.home"); returns the user's home
directory, which is what we use throughout our examples.
Name: Mark Ven Lambot Date: May 20, 2021
Year and Section: BSIS 2-D Contact Number: 09109701217

3.) A Random Access file functions similarly to a wide array of bytes in the file system. The file
pointer is a type of cursor or index into the implied array; input operations read bytes beginning at
the file pointer and advance the file pointer past the bytes read.
4.) Ordinary Files – Ordinary files are used to store data such as text, graphics, and images. The
information fed by the user is saved in these folders. Ordinary files include notepads, paint
programs, programming applications, and so on.

Directory Files – Directory files are simply a place/area/location where file information is stored.
It includes information such as file names, ownership, file size, and the date and time they were
created and last modified.

Device Files – Special files are also known as device files.


They are provided by the operating system as a mediator between the operating system and
hardware such as printers, plotters, and other devices, and are located in the "/dev" subdirectory.

FIFO Files – Between processes, FIFO files serve as an input/output channel.


As the name implies, it keeps track of the order in which users and other devices request and react
to files.

5.) The Path Class – A path in the file system is represented programmatically by the Path class. A
Path object is used to inspect, locate, and manipulate files. It contains the file name and directory
list used to create the path.

The code snippet below creates a Path instance and then calls multiple methods to get details
about it:

// None of these methods requires that the file corresponding


// to the Path exists.
// Microsoft Windows syntax
Path path = Paths.get("C:\\home\\joe\\foo");

This is the result in Microsoft Windows:

C:\home\joe\foo

You might also like