DataStream

package com.tz.util;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

/**
 * 可以用于操作基本数据类型的流对象
 * @author Administrator
 *
 */
public class DataStreamDome {
 public static void main(String[] args) throws IOException {
 OutputStreamWriter osw=new OutputStreamWriter(new FileOutputStream("txt.txt"),"UTF-8");//转换数据类型
 osw.write("");
 osw.close();
 }
 public static void readUTFDemo(){
  
 }
 public static void writeData() throws IOException{
  DataOutputStream dos=new DataOutputStream(new FileOutputStream("DATA.TXT"));
  dos.writeInt(234);
  dos.writeBoolean(true);
  dos.writeDouble(12.33);
  dos.close();
 }
 public static void readData() throws IOException{
  DataInputStream dis=new DataInputStream(new FileInputStream("txt.txt"));
  int num=dis.readInt();
  boolean b=dis.readBoolean();
  double d=dis.readDouble();
  dis.close();
 }
 public static void writeUTFDemo() throws IOException{
  DataOutputStream dos=new DataOutputStream(new FileOutputStream("txt.d"));
  dos.writeUTF("");
  dos.close();
 }
}

你可能感兴趣的:(DataStream)