小编kb4*_*000的帖子

将Java数组存储到文件中以进行读写

我对StackOverflow还是很陌生,所以很抱歉如果这个问题写得不正确。

我目前正在学习Java,并且正在寻找一种将一组数组存储为文件的方法,以便对数组的更改将在程序的不同实例之间持久存在。我需要阅读一份对最佳时间列表的任何更改写入文件。

我已经对存储数组进行了一些研究,但是我所读的大部分内容似乎只存储了一个简单的字符串,整数等数组。这些数组稍微复杂一点,所以我不确定该怎么做。我不希望有人为我编写所有代码,但是我可以在知道从哪里开始时使用一些帮助。

这是需要存储的样本数据。这是Java游戏的最佳时机。

是否存在将此类数据存储在某种文件中的方法?

public class BestTimes 
    {
        BestTimes[] beginner = new BestTimes[10];
        BestTimes[] intermediate = new BestTimes[10];
        BestTimes[] expert = new BestTimes[10];

        public BestTimes() {
        beginner[0] = new BestTimes(1, "John", 10.5);
        beginner[1] = new BestTimes(2, "James", 20.3);
        beginner[2] = new BestTimes(3, "Jill", 30);
        beginner[3] = new BestTimes(4, "Bill", 35);
        beginner[4] = new BestTimes(5, "Kevin", 40);
        beginner[5] = new BestTimes(6, "Nate", 55);
        beginner[6] = new BestTimes(7, "Bob", 75);
        beginner[7] = new BestTimes(8, "Dan", 85);
        beginner[8] = new BestTimes(9, "Amy", …
Run Code Online (Sandbox Code Playgroud)

java arrays file

1
推荐指数
1
解决办法
6711
查看次数

标签 统计

arrays ×1

file ×1

java ×1