} }
}
}
f.writeUTF(s);
f.seek(f.length());
{
System.out.println(s);
else
if (ss)
System.exit(0);
BufferedReader keyin = new BufferedReader(new InputStreamReader(
System.in));
String s;
RandomAccessFile f = new RandomAccessFile(\, \); boolean ss;
while ((s = keyin.readLine()) != null) {
ss = s.endsWith(\);
5、从键盘输入一个整型数,一个双精度型和一个字符串,用DataOutputStream 将这些数据输出到文件中,然后用DatalnputStream从文件中读出这些数据并打 印到标准输出设备
package com.devon.demo01;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.IOException;
public class TestDataOutputStream {
double d = Double.parseDouble(bf.readLine());
System.out.println(\);
float f = Float.parseFloat(bf.readLine());
System.out.println(\);
int i = Integer.parseInt(bf.readLine());
System.out.println(\);
DataOutputStream dOut = new DataOutputStream(fOut);
FileOutputStream fOut = new FileOutputStream(newFile);
try {
\);
File newFile = new File(
BufferedReader bf = new BufferedReader(new
InputStreamReader(System.in));
public static void main(String[] args) throws IOException {
}
}
System.out.println(\);
boolean b = new Boolean(bf.readLine()).booleanValue(); dOut.writeInt(i); dOut.writeFloat(f); dOut.writeDouble(d); dOut.writeBoolean(b); dOut.close();
} catch (FileNotFoundException e) {
System.out.println(e);
} catch (IOException e) { }
System.out.println(e);
6、一个窗口中,在四个位置循环显示四种不同颜色的正方形,当鼠标点击 时,停止循环显示,再次点击,恢复显示
package com.devon.demo01;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CycleRecTest extends JFrame {
public static void main(String[] args) }
});
}
pane.play();
else
pane.stop();
if (pane.isPlay())
{
public void mouseClicked(MouseEvent e)
{
addMouseListener(new MouseAdapter()
content.add(pane, \);
content.setLayout(new BorderLayout());
Container content = getContentPane();
final CycleRec pane = new CycleRec();
setSize(470, 470);
setTitle(\图形循环显示\); {
public CycleRecTest() JButton stopButton; JButton playButton;
}
class CycleRec extends JPanel implements Runnable {
{
if (imgID == 0) {
public void paintComponent(Graphics g) } {
public CycleRec() boolean bPlay = true; int imgID = 0;
private Color greenCor = Color.green; private Color cyanCor = Color.cyan; private Color blueCor = Color.blue; private Color blackCor = Color.black; private Thread show; }
app.setVisible(true);
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JFrame app = new CycleRecTest(); {