⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filewritertest.java

📁 java练习程序
💻 JAVA
字号:
//
//下面是一个英语单词填空小程序


import java.applet.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
class FileWriterWindow extends Frame implements ActionListener
{
	TextArea text; BufferedWriter out;   Button button;
	FileWriter tofile;
	FileWriterWindow()
	{
		super("流的写入");
		text=new TextArea(10, 10);
		text.setBackground(Color.cyan);
		try 
		{
			tofile=new FileWriter("hello.txt");
			out=new BufferedWriter(tofile);
		}
		catch(FileNotFoundException e)
		{}
		catch(IOException e)
		{}
		button =new Button("写入");
		button.addActionListener(this);
		setLayout(new BorderLayout());
		setSize(60, 70);
		setVisible(true);
		add(text, "Center");
		add("South", button);
		addWindowListener(new WindowAdapter()
		{
			public void windowClosing(WindowEvent e)
			{
				setVisible(false);
				System.exit(0);  
			}
		});
	}
	
	public void actionPerformed(ActionEvent e)
	{
		String s;
		if(e.getSource()==button)
		try
		{
			out.write(text.getText(), 0,(text.getText()).length());
			out.flush();
		}
		catch(IOException exp)
		{
			System.out.println(" have problem");
		}
	}
}

public class FileWriterTest
{
	public static void main(String args[])
	{
		FileWriterWindow w=new FileWriterWindow();
		w.pack();
	}
}

⌨️ 快捷键说明

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