What is the importance DataInputStream and DataOutputStream....???
How can i write a human readable file, that contains double,int,String values...
I tried it with DataOutputStream...But it is not human readable....(possible to read from DataInputStream)
How can i create a human readable file ??? (By using Writer or OutputStream)
//"MyFile.txt" data should contain in a tabular format.(like this,..)
price unit descs
19.99 12 Java T-shirt
9.99 8 Java Mug
15.99 13 Duke Juggling Dolls
3.99 29 Java Pin
4.99 50 Java Key Chain
import java.io.*;
public class DataIOStream{
public static void main(String args[]) throws Exception{
DataOutputStream out = new DataOutputStream(new FileOutputStream("MyFile.txt"));
double[] prices = { 19.99, 9.99, 15.99, 3.99, 4.99 };
int[] units = { 12, 8, 13, 29, 50 };
String[] descs = { "Java T-shirt",
"Java Mug",
"Duke Juggling Dolls",
"Java Pin",
"Java Key Chain" };
for(int i=0;i<prices.length;i++){
out.writeDouble(prices);
out.writeChar('\t');
out.writeInt(units[i]);
out.writeChar('\t');
out.writeChars(descs[i]);
out.writeChar('\n');
}
out.close();
}
}
:-)