网络编程实验报告(5)

2019-08-03 14:54

} }

}

}

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(); {


网络编程实验报告(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:建筑工程施工技术与管理复习题答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: