logo

CS4348 - Operating Systems Concepts

7 Pages2002 Words167 Views
   

Operating Systems Concepts (CS4348)

   

Added on  2021-12-15

CS4348 - Operating Systems Concepts

   

Operating Systems Concepts (CS4348)

   Added on 2021-12-15

ShareRelated Documents
Report on Java Project
In this project, the different segments and they are as follows:
1. Display a file
2. Display the file table
3. Display the free space bitmap
4. Display a disk block
5. Copy a file from the simulation to a file on the real system
6. Copy a file from the real system to a file in the simulation
7. Delete a file
8. Image Process
9. Exit
In the preceding section, the codes will be described. In this code, several functions are defined to execute
the process above.
Packages Required:
Package in java can be incorporated using “import” keyword. The import of required packages as as
follows:
import java.io.* : Employed for IO operation
import java.util.* : Employed for diffetent operations like input and output stream
import java.io.File:
import java.io.FileFilter :
import java.io.FilenameFilter :
import javax.swing.filechooser.* :
import java.nio.file.Files :
import java.nio.file.*: These packages are used for File related operations like File Handling, File
manipulation etc.
import java.io.IOException: This one is used for exception handling for IO operation
import java.awt.image.BufferedImage: This package is used for Image related operations like, image
access, image process etc.
import javax.imageio.ImageIO: This is used for accessing image in AWT window.
Display a file
Code:
void DisplayFile()
{
System.out.println("Welcome to Display File Section");
String arr[]={};
InputStream istr;
OutputStream ostr;
CS4348 - Operating Systems  Concepts_1
int c;
final int EOF = -1;
ostream = System.out;
try {
File inputFile = new File("File-1.txt");
istr = new FileInputStream(inputFile);
try {
while ((c = istream.read()) != EOF)
ostr.write(c);
} catch (IOException e) {
System.out.println("Exception caught");
Project.main(arr);
} finally {
try {
istream.close();
ostr.close();
} catch (IOException e) {
System.out.println("File not closed");
Project.main(arr);
}
Project.main(arr);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
Project.main(arr);
}
Project.main(arr);
}
Discussion: In this section, a file stored in a directory will be shown with its content. After successful
operation, the list of preferences will be shown by calling of main function Project.main(arr).
Display the file table
Code:
void DisplayFileTable()
{
System.out.println("Welcome to Display File Table Section");
String path = "D:/As Freelancer/Live Assignment/Manjula letter and Contents/31.Java
Programming(Dec 30,2018)";
File direc = new File(path);
String[] files = direc.list();
if (files.length == 0) {
System.out.println("Empty Directory");
} else {
for (String singFile : files) {
System.out.println(singFile);
}
}
CS4348 - Operating Systems  Concepts_2
String arr[]={};
Project.main(arr);
}
Discussion: In this section, the file table is being shown. After successful operation, the list of preferences
will be shown by calling of main function Project.main(arr).
Display the free space bitmap
Code:
void DiskSpaceDetails()
{
System.out.println("Welcome to Free Space Display Section");
File file = new File("c:");
long ts = file.getTotalSpace();
long us = file.getUsableSpace();
long fs = file.getFreeSpace();
System.out.println("Showing Disc Space Map");
System.out.println(Long.toBinaryString(ts));
System.out.println(Long.toBinaryString(us));
System.out.println(Long.toBinaryString(fs));
String arr[]={};
Project.main(arr);
}
Discussion: In this section, disc space bitmap will be shown in binary. This is actually showing the space
block of a disc.After successful operation, the list of preferences will be shown by calling of main
function Project.main(arr).
Display a disk block
Code:
void DiscBlock()
{
System.out.println("Welcome to Display Disc Block Section");
System.out.println("File system roots returned by
FileSystemView.getFileSystemView():");
FileSystemView fv = FileSystemView.getFileSystemView();
File[] rts = fv.getRoots();
for (int i = 0; i < rts.length; i++)
{
System.out.println("Root: " + rts[i]);
}
System.out.println("Directory: " + fv.getHomeDirectory());
System.out.println("System returns:");
File[] fl = File.listRoots();
for (int i = 0; i < fl.length; i++)
{
System.out.println("Drive: " + fl[i]);
CS4348 - Operating Systems  Concepts_3

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
CS4348 - Operating Systems Concepts
|5
|1324
|177