-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPracticalViva.java
More file actions
36 lines (30 loc) · 864 Bytes
/
PracticalViva.java
File metadata and controls
36 lines (30 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.sql.*;
import java.util.*;
import java.io.*;
public class PracticalViva{
public static void main(String args[]){
Scanner input=new Scanner(System.in);
String bookName,author;
int bookId;
System.out.print("Enter Book Name ->");
bookName=input.next();
System.out.print("Enter Author ->");
author=input.next();
System.out.print("Enter Book Id ->");
bookId=input.nextInt();
try{
BufferedWriter fl=new BufferedWriter(new FileWriter("practical.txt",true));
fl.write(bookName+" "+author+" "+bookId);
System.out.println("\n\t**The Contents of the file are**");
BufferedReader rd=new BufferedReader(new FileReader("practical.txt"));
while(rd.read()!=-1){
System.out.print(rd.readLine);
}
// fl.close();
rd.close();
}catch(Exception e){
System.out.println(e.toString());
}
input.close();
}
}