编写一个java程序将100,101,102,103,104,105这6个数以数组的形式写入到D:test.t

编写一个java程序将100,101,102,103,104,105这6个数以数组的形式写入到D:test.t,第1张

你问的不明白,我在代码里给你写了,你自己看吧

import java.io.FileWriter

import java.io.IOException

import java.util.Date

import java.util.Scanner

public class Test {

    public static void main(String[] args) {

        // 100,101,102,103,104,105

        // 你问的不明不白,这6个数是一个字符串还是说是要求一个一个输入然后保存

        // step1:字符串

        String str = "100,101,102,103,104,105"

        str = "[" + str + "]\n"

        append2File("D:\\test.txt", str)

        // step2: 手动输入

        Scanner sc = new Scanner(System.in)

        StringBuilder str2 = new StringBuilder("[")

        int i = 0

        System.out.println("输入6个数")

        while (i < 6) {

            int number = sc.nextInt()

            str2.append(number).append(",")

            i++

        }

        str2 = str2.deleteCharAt(str2.length() - 1).append("]\n")

        append2File("D:\\test.txt", str2.toString())

    }

    public static void append2File(String path, String content) {

        FileWriter writer = null

        try {

            // 打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件

            writer = new FileWriter(path, true)

            writer.write(content)

        } catch (IOException e) {

            e.printStackTrace()

        } finally {

            if (writer != null) {

                try {

                    writer.close()

                } catch (IOException e) {

                    e.printStackTrace()

                }

            }

            System.out.println(" *** 作完成.." + new Date())

        }

    }

}

import java.io.*

class test15 {

    public static void main(String[] args) {

        int[] aa = {

            101, 102, 103, 104, 105

        }

        File file = new File("D:/test.txt") 

        //***答案编写开始位置***

        try {

            FileWriter fw = new FileWriter(file)

            for (int i = 0 i < aa.length i++) {

                fw.write(aa[i])

                if (i < aa.length - 1) {

                    fw.write(",")

                }

            }

            fw.flush()

            fw.close()

        } catch (Exception e) {

            System.err.println(e.toString())

        }

        for (int i = aa.length - 1 i >= 0 i--) {

            System.out.print(aa[i] + " ")

        }

        //***答案编写结束位置***

    }

}

在工业应用上支持 104 规约等。软件 默认配置下不支持 61850 的 MMS 报文解析。截取的报文显示如下:在 Protocol 一栏显示 为 PRES。 通过查阅 Wireshark 官网可通过更改以下配置来支持 IEC61850 MMS 报文解析。 依次打开“Edit”—>“Preferences”在左侧 Protocols 栏下选中 PRES 选项,点击 右侧“Users Context Lists”选项中的 Edit 按钮,在d出下图中的菜单栏按如下图配置:


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/8132089.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-13
下一篇 2023-04-13

发表评论

登录后才能评论

评论列表(0条)

保存