码迷,mamicode.com
首页 > 其他好文 > 详细

类型流DataInputstream 和DataOutputStream的用法

时间:2019-11-10 10:27:58      阅读:71      评论:0      收藏:0      [点我收藏+]

标签:tin   ssi   stat   otf   tor   dde   ESS   void   sep   

package test;
 
 
import java.io.*;
import java.sql.SQLClientInfoException;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.zip.InflaterInputStream;
 
import javax.annotation.processing.FilerException;
import javax.management.RuntimeErrorException;

import privateclass.Filterby_Name;
import privateclass.Filterby_hidden;
import privateclass.Filterby_java;
import privateclass.MyBufferedReader;
import privateclass.Person;
 
public class Main {
 
    private static final String space_operator = " ";
    private static final double pi = Math.PI;
    private static final String LINE_SEPARATOR = System.getProperty("line.separator");
	private static final int SIZE = 1024*1024;

	
    public static void main(String[] args) throws Exception {

    	doswrite();
    	disread();
    	
    	
    }


	public static void disread() throws FileNotFoundException, IOException {
		DataInputStream dis = new DataInputStream(new FileInputStream("data.txt"));
    	String string = dis.readUTF();
    	int a = dis.readInt();
    	System.out.println(string);
    	System.out.println(a);
	}


	public static void doswrite() throws FileNotFoundException, IOException {
		DataOutputStream dos = new DataOutputStream(new FileOutputStream("data.txt"));
    	//这个utf开头会带有标识所以只能用类型流读出
		dos.writeUTF("小朋友哥哥给你买糖吃");
    	dos.writeInt(99);
	}
}

  

类型流DataInputstream 和DataOutputStream的用法

标签:tin   ssi   stat   otf   tor   dde   ESS   void   sep   

原文地址:https://www.cnblogs.com/WINDZLY/p/11828661.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!