程序!编写程序将10个整型数写入一个文件中,然后再从该文件中将这10个数读出并显示!谁帮忙写呀?明天要用的!

来源:百度知道 编辑:UC知道 时间:2024/06/05 18:01:58
对了,用JAVA程序语言写的呀,谢
有没有精确一点的呀!帮帮忙啦,大家用

import java.io.*;
import java.nio.*;
import java.nio.channels.FileChannel;

public class PrimesToFile {
public static void main(String[] args) {
int primesRequired = 100; // Default count
if (args.length > 0) {
try {
primesRequired = Integer.valueOf(args[0]).intValue();
} catch (NumberFormatException e) {
System.out.println("Prime count value invalid. Using default of "
+ primesRequired);
}
}

long[] primes = new long[primesRequired]; // Array to store primes
primes[0] = 2; // Seed the first prime
primes[1] = 3; // and the second
// Count of primes found - up to now, which is also the array index
int count = 2;
// Next integer to be tested
long number = 5;

outer: