import java.io.*;
public class IO_Tester {
public static void main() {
System.out.println("Dwste enan akeraio:");
int i = readInt();
System.out.println("Dwste enan float:");
float f = readFloat();
System.out.println("Dwste ena string:");
String s = readString();
System.out.println("Dwste mia boolean:");
boolean b = readBoolean();
System.out.println("i="+i+"\tf="+f+"\ts="+s+"\tb="+b);
try {
FileOutputStream fil = new FileOutputStream(s);
BufferedOutputStream buf = new BufferedOutputStream(fil);
DataOutputStream dat = new DataOutputStream(buf);
dat.writeInt(i);
dat.writeFloat(f);
dat.writeBoolean(b);
dat.close();
} catch (FileNotFoundException e) {}
catch (IOException e) {}
try {
FileInputStream fil = new FileInputStream(s);
BufferedInputStream buf = new BufferedInputStream(fil);
DataInputStream dat = new DataInputStream(buf);
i+=dat.readInt();
f*=dat.readFloat();
b=!dat.readBoolean();
dat.close();
} catch (FileNotFoundException e) {}
catch (IOException e) {}
System.out.println("i="+i+"\tf="+f+"\ts="+s+"\tb="+b);
}
public static int readInt() {
byte b[] = new byte[16];
String str;
try {
System.in.read(b);
str = (new String(b)).trim();
return Integer.parseInt(str);
} catch (IOException e) {
System.out.println("Exception: " + e.toString());
return 0;
} catch (NumberFormatException e) {
System.out.println("Exception: " + e.toString() + "\n Returned value: -1");
return -1;
}
}
public static float readFloat() {
byte b[] = new byte[16];
String str;
try {
System.in.read(b);
str = (new String(b)).trim();
return Float.parseFloat(str);
} catch (IOException e) {
System.out.println("Exception: " + e.toString());
return 0;
}catch (NumberFormatException e){
System.out.println("Exception: " + e.toString() + "\n Returned value: -1");
return -1;
}
}
public static String readString() {
byte b[] = new byte[32];
String str;
try {
System.in.read(b);
str = (new String(b)).trim();
return str;
} catch (IOException e) {
System.out.println("Exception: " + e.toString());
return "";
}
}
public static boolean readBoolean() {
byte b[] = new byte[16];
String str;
try {
System.in.read(b);
str = (new String(b)).trim();
Boolean bool = new Boolean(str);
return bool.booleanValue();
} catch (IOException e) {
System.out.println("Exception: " + e.toString());
return false;
}
}
}