filedemo9.java

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

JAVA
26
字号
/**
*This is a program that uses FileOututStream to write a string to the file called Bob.txt
*The contents of the file are displayed on the screen using the type command on the command prompt
*You can use "type + filename.txt" to see the content of the file!
*2004.12.30. xhcprince
*/

import java.io.*;

class fileDemo9
{
	public static void main(String args[]) throws IOException
	{
		byte[] b = new byte[111];

		System.out.println("Enter a string which will be saved to disk:");

		int bytes = System.in.read(b);
		FileOutputStream fout = new FileOutputStream("D:/my.doc");
	/*----------------------------------------------------------------------------------------------
		The file should be actual exist,or there may be an Exception!
		It won't be created automatically!
	----------------------------------------------------------------------------------------------*/
		fout.write(b,0,bytes);
	}
}

⌨️ 快捷键说明

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