我在将数组获取到字符串中的文本文件时遇到问题。到目前为止我的代码:
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
}
}
}
我将如何使用我创建的数组将其移动到文本文件中?