Taking inputs and Buffer Class
Print —> belongs to print Stream class
out —> null object created as static variable inside System Class when calling .. Print Stream so, out is object of type Print Stream
in ——> object in , is of type Input Stream
.read( ) —> throw IOexception and return int (ASCI value ), Read only one character at a time i.e for reading 555, use loop
int num = Sytem.in.read( ) //num will store ASCI /// to get original no —> num- 48
.readLine( ) —> throw IOexception ,, Reads String
Buffer Reader —> under package <u>i.o</u> — > java.io.IOException, java.io.BufferReader
InputStreamReader <u>isr</u> = new InputStreamReader (<u>*System.in*</u>)
BufferReadered br = new BufferReadered (<u>isr</u>);
—> can take input from InputStreamReader , FIle , Network , Keyboard
int num = br.readLine( )
— > Reads String
int num = Integer.parseInt(br.readLine( ))
— > Reads Integer (32 bit)
char c = (char) br.read ( ) —> read character
/// all parse Lines
int num = Float.parseFloat(br.readLine( ))
— > Reads Float (upto 6 decimal)
int num = Double.parseDouble(br.readLine( ))
— > Reads Double (upto 15 deci)
int num = Long.parseLong(br.readLine( ))
— > Reads Double (64 bit)
int num = Short.parseShort(br.readLine( ))
— > Reads Short(16 bit)
br.close( ) → close after using buffer reader
Scanner Class and methods —> inside util package
Scanner sc = new Scanner( System.in )
Expection and error ,
@SuppressWarnings("unchecked")
,, how to handle and which java version to use
File Handling
//creating file
File myObj = new File("students.txt");
myObj.createNewFile();
//writing on a file
FileWriter file = new FileWriter("students.txt");
file.write("This file has information of Teachers");
file.close();
//reading
File file = new File("Teachers.txt");
Scanner myReader = new Scanner(file);
while (myReader.hasNextLine()) {
String data = myReader.nextLine();
System.out.println(data);
}
myReader.close();
//deleting
if (file.delete()) {
System.out.println("Deleted Successfully: " + file.getName());
String
all methods of string
scanner
math
java
io