数据流的问题
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
//import
java.io.FileNotFoundException;
import java.io.FileOutputStream;
import
java.io.IOException;
public class DataInputStreamT {
public static void main(String[] args) throws
IOException {
FileOutputStream fos=new FileOutputStream("d:/mydoc/s3.txt");
DataOutputStream dos=new DataOutputStream(fos);
Float[] price={105.5f,65.5f,59.5f};
String[] name={"java","sql","jsp"};
int[] num={10,15,20};
for(int i=0;i<name.length;i++){
dos.writeUTF(name[i]);
dos.writeByte(num[i]);
dos.writeFloat(price[i]);
//System.out.println("\n");
}
fos.close();
dos.close();
FileInputStream fis=new FileInputStream("d:/mydoc/s3.txt");
DataInputStream dis=new DataInputStream(fis);
String name_read;
int num_read;
Double pirce_read;
Double total = null;
System.out.println("您的订单如下:");
System.out.println("书名"+"\t\t"+"数量"+"\t\t"+"单价");
while(dis.available()!=0){
name_read=dis.readUTF();
num_read=dis.readInt();
pirce_read=(double) dis.readFloat();
System.out.println(name_read+"\t\t"+num_read+"\t\t"+"$"+pirce_read);
total=total+num_read*pirce_read;
}
fis.close();
dis.close();
------解决方案--------------------
囧了.你在干什么?
------解决方案--------------------
什么情况?