My question is, whether it is direct use, as shown below;
class Test{
public static void main(String args[]){
try{
FileWriter fo =new FileWriter("somex.txt");
int arr[] = {9};
for(int i =0; i <arr.length; i++){
fo .write(arr[i]); // this is very costly.
}
fo.write(b);
fo.close();
System.out.println("....");
}catch(Exception e){system.out.println(e);}
}
}
OR
coding it more efficient as shown below;
class Test{
public static void main(String args[])throws Exception{
BufferedWriter bfw= new BufferedWriter(new FileWriter("foo.out")));
int arr[] = {9};
for(int i =0; i <arr.length; i++){
bfw .write(arr[i]);
}
bfw.flush();
bfw.close();
System.out.println(".......");
}
}
There is no difference because both will do same write operation. Can someone help me understand the subtleness?