filedemo14.java

来自「JAVA程序设计课程中各章节的程序实例。」· Java 代码 · 共 44 行

JAVA
44
字号
/**
*This program write a single character to the file system and then 
* read it back and print it to the console.
*Compile two programs seperately!
*2005.1.1. xhcprince:)
*/

	/*----------------------------------------------------------------------------------
		The DataInputStream and DataOutputStream are used to read binary representations
		of java primitives in a portable way.It gives yo access to a range of methods
		such as readInt(),readDouble(),etc (however, there's not a writeLine() method,so
		I don't know how to input a String) that will work  the same 
		on different  platforms
	*---------------------------------------------------------------------------------*/

//write the file//
import java.io.*;

public class fileDemo14
{
	public static void main(String args[]) throws IOException
	{
		FileOutputStream fout = new FileOutputStream("fout.dat");
		DataOutputStream dout = new DataOutputStream(fout);
		
		dout.writeChar('j');
	}
}


//read the file//
/*
import java.io.*;
public class fileDemo14
{
	public static void main(String args[]) throws IOException
	{
		FileInputStream fin = new FileInputStream("fout.dat");
		DataInputStream din = new DataInputStream(fin);
		
		System.out.println(din.readChar());
	}
}
*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?