Skip to content

Commit

Permalink
Create exceptHaandling.java
Browse files Browse the repository at this point in the history
  • Loading branch information
harikrishnan669 authored Nov 17, 2023
1 parent 3e5dbc8 commit cf23338
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions exceptHaandling.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.IOException;
class input{
void scan() throws IOException {
try {
FileOutputStream fr=new FileOutputStream("hello.txt");
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a line of text");
String line=bf.readLine();
fr.write(line.getBytes());
fr.close();
}
catch(IOException e) {
e.printStackTrace(); }
}
}
class output{
void print() throws IOException {
try {
BufferedReader bff=new BufferedReader(new FileReader("hello.txt"));
FileReader fr1=new FileReader("hello.txt");
String contents;
while((contents=bff.readLine())!=null) {
System.out.println(contents);
}
}catch(IOException e) {
e.printStackTrace();
}
}
}
public class nands {

public static void main(String[] args) throws IOException{
input in=new input();
in.scan();
output ou=new output();
ou.print();

}

}

0 comments on commit cf23338

Please sign in to comment.