1

文字列のテキスト ファイルに配列を取得する際に問題が発生しています。これまでの私のコード:

public class ArrayList 
{

    public static void main(String[] args) throws IOException
    {

        int myArray [] = new int [20]; 

        for (int i = 0 ; i < 20 ; i++) { 
                        myArray [i] = (int) (Math.random () * 8);
            System.out.print(myArray[i]);
            String s1 = Arrays.toString(myArray);
            System.out.println(s1);

            s1 = "/Users/EricDkim/Desktop/FileIOTest/pfile.txt";
            File f = new File(s1);
            FileOutputStream fileOut = new FileOutputStream(f);

            byte value = 0x63; //By adding 0x it reads it as hex
            DataOutputStream dataOut = new DataOutputStream(fileOut);
            //dataoutputstream is used to write primitive java
            //data types (byte, int, char, double) and strings are to a file or a socket
            dataOut.writeByte(value);

            //creates 20 numbers
        }

    }

}

作成した配列を使用してテキスト ファイルに移動するにはどうすればよいですか?

4

2 に答える 2