SlideShare a Scribd company logo
// import required package file
import java.io.File;
// The Filedetails class
public class FileDetails {
// Constructor that performs the action
public FileDetails(String filename)
{
// File object to get details
File file=new File(filename);
// printing obsolute path
System.out.println("Absolute path of file:"+file.getAbsolutePath());
// printing file size in bytes
System.out.println("File Size in bytes:"+file.length());
// Checking if file is readable
if(file.canRead())
System.out.println("The file is readable");
else
System.out.println("The file is not readable");
// checking if file is writable
if(file.canWrite())
System.out.println("The file is writable");
else
System.out.println("The file is not writable");
}
// main method goes here
public static void main(String[] args) {
// TODO Auto-generated method stub
// object instantiation
FileDetails fd=new FileDetails("anyfile.doc"); // You should give exact path and file name
here
}
}
// Importing required packages
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
// the writestring class
public class WriteString {
// Writestring class
public WriteString(String filename,String text) throws FileNotFoundException
{
// File object
File file=new File(filename);
// Printsteam class that connects file using file output stream
PrintStream ps=new PrintStream(new FileOutputStream(file));
// using println method to write to the file
ps.println(text);
}
// main method to execute the code
public static void main(String[] args) throws FileNotFoundException
{
// the writestring class instantiation
WriteString ws=new WriteString("f1.txt","Hello World"); // You should give exact path
and file name here
}
}
// importing packages
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
// The writints class
public class WriteInts {
// the constructor to instantiate
public WriteInts(String filename,int[] myArr) throws FileNotFoundException
{
// File object
File file=new File(filename);
// Using print stream to write integers
PrintStream ps=new PrintStream(new FileOutputStream(file));
//Looping through array elements to write every element
for(int i=0;i
Solution
// import required package file
import java.io.File;
// The Filedetails class
public class FileDetails {
// Constructor that performs the action
public FileDetails(String filename)
{
// File object to get details
File file=new File(filename);
// printing obsolute path
System.out.println("Absolute path of file:"+file.getAbsolutePath());
// printing file size in bytes
System.out.println("File Size in bytes:"+file.length());
// Checking if file is readable
if(file.canRead())
System.out.println("The file is readable");
else
System.out.println("The file is not readable");
// checking if file is writable
if(file.canWrite())
System.out.println("The file is writable");
else
System.out.println("The file is not writable");
}
// main method goes here
public static void main(String[] args) {
// TODO Auto-generated method stub
// object instantiation
FileDetails fd=new FileDetails("anyfile.doc"); // You should give exact path and file name
here
}
}
// Importing required packages
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
// the writestring class
public class WriteString {
// Writestring class
public WriteString(String filename,String text) throws FileNotFoundException
{
// File object
File file=new File(filename);
// Printsteam class that connects file using file output stream
PrintStream ps=new PrintStream(new FileOutputStream(file));
// using println method to write to the file
ps.println(text);
}
// main method to execute the code
public static void main(String[] args) throws FileNotFoundException
{
// the writestring class instantiation
WriteString ws=new WriteString("f1.txt","Hello World"); // You should give exact path
and file name here
}
}
// importing packages
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
// The writints class
public class WriteInts {
// the constructor to instantiate
public WriteInts(String filename,int[] myArr) throws FileNotFoundException
{
// File object
File file=new File(filename);
// Using print stream to write integers
PrintStream ps=new PrintStream(new FileOutputStream(file));
//Looping through array elements to write every element
for(int i=0;i

More Related Content

Similar to import required package file import java.io.File; The Filed.pdf

File Input & Output
File Input & OutputFile Input & Output
File Input & Output
PRN USM
 
Diploma ii cfpc- u-5.2 pointer, structure ,union and intro to file handling
Diploma ii  cfpc- u-5.2 pointer, structure ,union and intro to file handlingDiploma ii  cfpc- u-5.2 pointer, structure ,union and intro to file handling
Diploma ii cfpc- u-5.2 pointer, structure ,union and intro to file handling
Rai University
 
pointer, structure ,union and intro to file handling
 pointer, structure ,union and intro to file handling pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handling
Rai University
 
Create a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdfCreate a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdf
shahidqamar17
 
2. Write a program which will open an input file and write to an out.pdf
2. Write a program which will open an input file and write to an out.pdf2. Write a program which will open an input file and write to an out.pdf
2. Write a program which will open an input file and write to an out.pdf
rbjain2007
 
DIWE - File handling with PHP
DIWE - File handling with PHPDIWE - File handling with PHP
DIWE - File handling with PHP
Rasan Samarasinghe
 
Java 7 - short intro to NIO.2
Java 7 - short intro to NIO.2Java 7 - short intro to NIO.2
Java 7 - short intro to NIO.2
Martijn Verburg
 
--import statemnts for Random- Scanner and IO import java-util-Random-.pdf
--import statemnts for Random- Scanner and IO import java-util-Random-.pdf--import statemnts for Random- Scanner and IO import java-util-Random-.pdf
--import statemnts for Random- Scanner and IO import java-util-Random-.pdf
ganisyedtrd
 
Input output files in java
Input output files in javaInput output files in java
Input output files in java
Kavitha713564
 
Data file operations in C++ Base
Data file operations in C++ BaseData file operations in C++ Base
Data file operations in C++ Base
arJun_M
 
Java 3 Computer Science.pptx
Java 3 Computer Science.pptxJava 3 Computer Science.pptx
Java 3 Computer Science.pptx
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
Csphtp1 17
Csphtp1 17Csphtp1 17
Csphtp1 17
HUST
 
10 sharing files and data in windows phone 8
10   sharing files and data in windows phone 810   sharing files and data in windows phone 8
10 sharing files and data in windows phone 8
WindowsPhoneRocks
 
Know how to redirect input and output- and know how to append to an ex.docx
Know how to redirect input and output- and know how to append to an ex.docxKnow how to redirect input and output- and know how to append to an ex.docx
Know how to redirect input and output- and know how to append to an ex.docx
wkelli
 
Files in PHP.pptx g
Files in PHP.pptx                      gFiles in PHP.pptx                      g
Files in PHP.pptx g
FiromsaDine
 
Cs1123 10 file operations
Cs1123 10 file operationsCs1123 10 file operations
Cs1123 10 file operationsTAlha MAlik
 

Similar to import required package file import java.io.File; The Filed.pdf (20)

File Input & Output
File Input & OutputFile Input & Output
File Input & Output
 
Diploma ii cfpc- u-5.2 pointer, structure ,union and intro to file handling
Diploma ii  cfpc- u-5.2 pointer, structure ,union and intro to file handlingDiploma ii  cfpc- u-5.2 pointer, structure ,union and intro to file handling
Diploma ii cfpc- u-5.2 pointer, structure ,union and intro to file handling
 
pointer, structure ,union and intro to file handling
 pointer, structure ,union and intro to file handling pointer, structure ,union and intro to file handling
pointer, structure ,union and intro to file handling
 
Create a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdfCreate a text file named lnfo.txt. Enter the following informatio.pdf
Create a text file named lnfo.txt. Enter the following informatio.pdf
 
2. Write a program which will open an input file and write to an out.pdf
2. Write a program which will open an input file and write to an out.pdf2. Write a program which will open an input file and write to an out.pdf
2. Write a program which will open an input file and write to an out.pdf
 
DIWE - File handling with PHP
DIWE - File handling with PHPDIWE - File handling with PHP
DIWE - File handling with PHP
 
Java 7 - short intro to NIO.2
Java 7 - short intro to NIO.2Java 7 - short intro to NIO.2
Java 7 - short intro to NIO.2
 
--import statemnts for Random- Scanner and IO import java-util-Random-.pdf
--import statemnts for Random- Scanner and IO import java-util-Random-.pdf--import statemnts for Random- Scanner and IO import java-util-Random-.pdf
--import statemnts for Random- Scanner and IO import java-util-Random-.pdf
 
Input output files in java
Input output files in javaInput output files in java
Input output files in java
 
My History
My HistoryMy History
My History
 
Data file operations in C++ Base
Data file operations in C++ BaseData file operations in C++ Base
Data file operations in C++ Base
 
Java 3 Computer Science.pptx
Java 3 Computer Science.pptxJava 3 Computer Science.pptx
Java 3 Computer Science.pptx
 
IO and threads Java
IO and threads JavaIO and threads Java
IO and threads Java
 
Csphtp1 17
Csphtp1 17Csphtp1 17
Csphtp1 17
 
History
HistoryHistory
History
 
10 sharing files and data in windows phone 8
10   sharing files and data in windows phone 810   sharing files and data in windows phone 8
10 sharing files and data in windows phone 8
 
Know how to redirect input and output- and know how to append to an ex.docx
Know how to redirect input and output- and know how to append to an ex.docxKnow how to redirect input and output- and know how to append to an ex.docx
Know how to redirect input and output- and know how to append to an ex.docx
 
Files in PHP.pptx g
Files in PHP.pptx                      gFiles in PHP.pptx                      g
Files in PHP.pptx g
 
File class.48
File class.48File class.48
File class.48
 
Cs1123 10 file operations
Cs1123 10 file operationsCs1123 10 file operations
Cs1123 10 file operations
 

More from anandinternational01

Sorry, the correct answer is D .pdf
                     Sorry, the correct answer is D                   .pdf                     Sorry, the correct answer is D                   .pdf
Sorry, the correct answer is D .pdf
anandinternational01
 
1) Aspartylglycosaminuriaa) What is the inheritance pattern of thi.pdf
1) Aspartylglycosaminuriaa) What is the inheritance pattern of thi.pdf1) Aspartylglycosaminuriaa) What is the inheritance pattern of thi.pdf
1) Aspartylglycosaminuriaa) What is the inheritance pattern of thi.pdf
anandinternational01
 
mollity = moles of solutemass of the solvent .pdf
                     mollity = moles of solutemass of the solvent    .pdf                     mollity = moles of solutemass of the solvent    .pdf
mollity = moles of solutemass of the solvent .pdf
anandinternational01
 
Devaluation Revaluation Increases imports Increases exports In.pdf
    Devaluation Revaluation   Increases imports Increases exports   In.pdf    Devaluation Revaluation   Increases imports Increases exports   In.pdf
Devaluation Revaluation Increases imports Increases exports In.pdf
anandinternational01
 
Project #4 Urban Population Dynamics This project will acquaint y.pdf
  Project #4 Urban Population Dynamics   This project will acquaint y.pdf  Project #4 Urban Population Dynamics   This project will acquaint y.pdf
Project #4 Urban Population Dynamics This project will acquaint y.pdf
anandinternational01
 
Triple bond complexes Cobalt forms complexes wit.pdf
                     Triple bond complexes  Cobalt forms complexes wit.pdf                     Triple bond complexes  Cobalt forms complexes wit.pdf
Triple bond complexes Cobalt forms complexes wit.pdf
anandinternational01
 
THE IMAGE IS NT HERE!!! .pdf
                     THE IMAGE IS NT HERE!!!                          .pdf                     THE IMAGE IS NT HERE!!!                          .pdf
THE IMAGE IS NT HERE!!! .pdf
anandinternational01
 
KNO2 is a strong salt KNO2 K+ + NO2- NO2- +.pdf
                     KNO2 is a strong salt  KNO2  K+ + NO2-  NO2- +.pdf                     KNO2 is a strong salt  KNO2  K+ + NO2-  NO2- +.pdf
KNO2 is a strong salt KNO2 K+ + NO2- NO2- +.pdf
anandinternational01
 
In general, the more hydrophobic ,less polar, and.pdf
                     In general, the more hydrophobic ,less polar, and.pdf                     In general, the more hydrophobic ,less polar, and.pdf
In general, the more hydrophobic ,less polar, and.pdf
anandinternational01
 
group IB, IIA, and IIB metals .pdf
                     group  IB, IIA, and IIB metals                   .pdf                     group  IB, IIA, and IIB metals                   .pdf
group IB, IIA, and IIB metals .pdf
anandinternational01
 
trapeziumSolutiontrapezium.pdf
trapeziumSolutiontrapezium.pdftrapeziumSolutiontrapezium.pdf
trapeziumSolutiontrapezium.pdf
anandinternational01
 
the units should be kJmolSolutionthe units should be kJmol.pdf
the units should be kJmolSolutionthe units should be kJmol.pdfthe units should be kJmolSolutionthe units should be kJmol.pdf
the units should be kJmolSolutionthe units should be kJmol.pdf
anandinternational01
 
the correct options are --1) There are several observations t.pdf
the correct options are --1)  There are several observations t.pdfthe correct options are --1)  There are several observations t.pdf
the correct options are --1) There are several observations t.pdf
anandinternational01
 
Q1. The answer is true. This is because there are over a million kno.pdf
Q1. The answer is true. This is because there are over a million kno.pdfQ1. The answer is true. This is because there are over a million kno.pdf
Q1. The answer is true. This is because there are over a million kno.pdf
anandinternational01
 
Stakeholders in the compensation arena are as followingShareholde.pdf
Stakeholders in the compensation arena are as followingShareholde.pdfStakeholders in the compensation arena are as followingShareholde.pdf
Stakeholders in the compensation arena are as followingShareholde.pdf
anandinternational01
 
PART 2SolutionPART 2.pdf
PART 2SolutionPART 2.pdfPART 2SolutionPART 2.pdf
PART 2SolutionPART 2.pdf
anandinternational01
 
problems while testing a program are Testing issues include the d.pdf
problems while testing a program are Testing issues include the d.pdfproblems while testing a program are Testing issues include the d.pdf
problems while testing a program are Testing issues include the d.pdf
anandinternational01
 
Occipital lobe-Houses area responsible for perception of vision and .pdf
Occipital lobe-Houses area responsible for perception of vision and .pdfOccipital lobe-Houses area responsible for perception of vision and .pdf
Occipital lobe-Houses area responsible for perception of vision and .pdf
anandinternational01
 
long term business benefits of integrated dataStrategic thinking .pdf
long term business benefits of integrated dataStrategic thinking .pdflong term business benefits of integrated dataStrategic thinking .pdf
long term business benefits of integrated dataStrategic thinking .pdf
anandinternational01
 
Molality = moles of ureakg of water= 0.1000.100 = 1.00 molkg.pdf
Molality = moles of ureakg of water= 0.1000.100 = 1.00 molkg.pdfMolality = moles of ureakg of water= 0.1000.100 = 1.00 molkg.pdf
Molality = moles of ureakg of water= 0.1000.100 = 1.00 molkg.pdf
anandinternational01
 

More from anandinternational01 (20)

Sorry, the correct answer is D .pdf
                     Sorry, the correct answer is D                   .pdf                     Sorry, the correct answer is D                   .pdf
Sorry, the correct answer is D .pdf
 
1) Aspartylglycosaminuriaa) What is the inheritance pattern of thi.pdf
1) Aspartylglycosaminuriaa) What is the inheritance pattern of thi.pdf1) Aspartylglycosaminuriaa) What is the inheritance pattern of thi.pdf
1) Aspartylglycosaminuriaa) What is the inheritance pattern of thi.pdf
 
mollity = moles of solutemass of the solvent .pdf
                     mollity = moles of solutemass of the solvent    .pdf                     mollity = moles of solutemass of the solvent    .pdf
mollity = moles of solutemass of the solvent .pdf
 
Devaluation Revaluation Increases imports Increases exports In.pdf
    Devaluation Revaluation   Increases imports Increases exports   In.pdf    Devaluation Revaluation   Increases imports Increases exports   In.pdf
Devaluation Revaluation Increases imports Increases exports In.pdf
 
Project #4 Urban Population Dynamics This project will acquaint y.pdf
  Project #4 Urban Population Dynamics   This project will acquaint y.pdf  Project #4 Urban Population Dynamics   This project will acquaint y.pdf
Project #4 Urban Population Dynamics This project will acquaint y.pdf
 
Triple bond complexes Cobalt forms complexes wit.pdf
                     Triple bond complexes  Cobalt forms complexes wit.pdf                     Triple bond complexes  Cobalt forms complexes wit.pdf
Triple bond complexes Cobalt forms complexes wit.pdf
 
THE IMAGE IS NT HERE!!! .pdf
                     THE IMAGE IS NT HERE!!!                          .pdf                     THE IMAGE IS NT HERE!!!                          .pdf
THE IMAGE IS NT HERE!!! .pdf
 
KNO2 is a strong salt KNO2 K+ + NO2- NO2- +.pdf
                     KNO2 is a strong salt  KNO2  K+ + NO2-  NO2- +.pdf                     KNO2 is a strong salt  KNO2  K+ + NO2-  NO2- +.pdf
KNO2 is a strong salt KNO2 K+ + NO2- NO2- +.pdf
 
In general, the more hydrophobic ,less polar, and.pdf
                     In general, the more hydrophobic ,less polar, and.pdf                     In general, the more hydrophobic ,less polar, and.pdf
In general, the more hydrophobic ,less polar, and.pdf
 
group IB, IIA, and IIB metals .pdf
                     group  IB, IIA, and IIB metals                   .pdf                     group  IB, IIA, and IIB metals                   .pdf
group IB, IIA, and IIB metals .pdf
 
trapeziumSolutiontrapezium.pdf
trapeziumSolutiontrapezium.pdftrapeziumSolutiontrapezium.pdf
trapeziumSolutiontrapezium.pdf
 
the units should be kJmolSolutionthe units should be kJmol.pdf
the units should be kJmolSolutionthe units should be kJmol.pdfthe units should be kJmolSolutionthe units should be kJmol.pdf
the units should be kJmolSolutionthe units should be kJmol.pdf
 
the correct options are --1) There are several observations t.pdf
the correct options are --1)  There are several observations t.pdfthe correct options are --1)  There are several observations t.pdf
the correct options are --1) There are several observations t.pdf
 
Q1. The answer is true. This is because there are over a million kno.pdf
Q1. The answer is true. This is because there are over a million kno.pdfQ1. The answer is true. This is because there are over a million kno.pdf
Q1. The answer is true. This is because there are over a million kno.pdf
 
Stakeholders in the compensation arena are as followingShareholde.pdf
Stakeholders in the compensation arena are as followingShareholde.pdfStakeholders in the compensation arena are as followingShareholde.pdf
Stakeholders in the compensation arena are as followingShareholde.pdf
 
PART 2SolutionPART 2.pdf
PART 2SolutionPART 2.pdfPART 2SolutionPART 2.pdf
PART 2SolutionPART 2.pdf
 
problems while testing a program are Testing issues include the d.pdf
problems while testing a program are Testing issues include the d.pdfproblems while testing a program are Testing issues include the d.pdf
problems while testing a program are Testing issues include the d.pdf
 
Occipital lobe-Houses area responsible for perception of vision and .pdf
Occipital lobe-Houses area responsible for perception of vision and .pdfOccipital lobe-Houses area responsible for perception of vision and .pdf
Occipital lobe-Houses area responsible for perception of vision and .pdf
 
long term business benefits of integrated dataStrategic thinking .pdf
long term business benefits of integrated dataStrategic thinking .pdflong term business benefits of integrated dataStrategic thinking .pdf
long term business benefits of integrated dataStrategic thinking .pdf
 
Molality = moles of ureakg of water= 0.1000.100 = 1.00 molkg.pdf
Molality = moles of ureakg of water= 0.1000.100 = 1.00 molkg.pdfMolality = moles of ureakg of water= 0.1000.100 = 1.00 molkg.pdf
Molality = moles of ureakg of water= 0.1000.100 = 1.00 molkg.pdf
 

Recently uploaded

"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 

Recently uploaded (20)

"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 

import required package file import java.io.File; The Filed.pdf

  • 1. // import required package file import java.io.File; // The Filedetails class public class FileDetails { // Constructor that performs the action public FileDetails(String filename) { // File object to get details File file=new File(filename); // printing obsolute path System.out.println("Absolute path of file:"+file.getAbsolutePath()); // printing file size in bytes System.out.println("File Size in bytes:"+file.length()); // Checking if file is readable if(file.canRead()) System.out.println("The file is readable"); else System.out.println("The file is not readable"); // checking if file is writable if(file.canWrite()) System.out.println("The file is writable"); else System.out.println("The file is not writable"); } // main method goes here public static void main(String[] args) { // TODO Auto-generated method stub // object instantiation FileDetails fd=new FileDetails("anyfile.doc"); // You should give exact path and file name here }
  • 2. } // Importing required packages import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; // the writestring class public class WriteString { // Writestring class public WriteString(String filename,String text) throws FileNotFoundException { // File object File file=new File(filename); // Printsteam class that connects file using file output stream PrintStream ps=new PrintStream(new FileOutputStream(file)); // using println method to write to the file ps.println(text); } // main method to execute the code public static void main(String[] args) throws FileNotFoundException { // the writestring class instantiation WriteString ws=new WriteString("f1.txt","Hello World"); // You should give exact path and file name here } } // importing packages import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; // The writints class public class WriteInts {
  • 3. // the constructor to instantiate public WriteInts(String filename,int[] myArr) throws FileNotFoundException { // File object File file=new File(filename); // Using print stream to write integers PrintStream ps=new PrintStream(new FileOutputStream(file)); //Looping through array elements to write every element for(int i=0;i Solution // import required package file import java.io.File; // The Filedetails class public class FileDetails { // Constructor that performs the action public FileDetails(String filename) { // File object to get details File file=new File(filename); // printing obsolute path System.out.println("Absolute path of file:"+file.getAbsolutePath()); // printing file size in bytes System.out.println("File Size in bytes:"+file.length()); // Checking if file is readable if(file.canRead()) System.out.println("The file is readable"); else System.out.println("The file is not readable"); // checking if file is writable if(file.canWrite()) System.out.println("The file is writable"); else System.out.println("The file is not writable");
  • 4. } // main method goes here public static void main(String[] args) { // TODO Auto-generated method stub // object instantiation FileDetails fd=new FileDetails("anyfile.doc"); // You should give exact path and file name here } } // Importing required packages import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; // the writestring class public class WriteString { // Writestring class public WriteString(String filename,String text) throws FileNotFoundException { // File object File file=new File(filename); // Printsteam class that connects file using file output stream PrintStream ps=new PrintStream(new FileOutputStream(file)); // using println method to write to the file ps.println(text); } // main method to execute the code public static void main(String[] args) throws FileNotFoundException { // the writestring class instantiation WriteString ws=new WriteString("f1.txt","Hello World"); // You should give exact path and file name here
  • 5. } } // importing packages import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; // The writints class public class WriteInts { // the constructor to instantiate public WriteInts(String filename,int[] myArr) throws FileNotFoundException { // File object File file=new File(filename); // Using print stream to write integers PrintStream ps=new PrintStream(new FileOutputStream(file)); //Looping through array elements to write every element for(int i=0;i