日期:2014-05-20 浏览次数:20707 次
import java.io.*; RandomAccessFile raf = new RandomAccessFile("test.txt", "rw"); short[] data = {1,2,3,4,5}; for (short s : data) { raf.writeShort((int)s); } raf.close();
------解决方案--------------------
PrintWriter writer = new PrintWriter(new FileWriter("result.txt"));
short[] numbers = ...;
for(short number: numbers){
writer.println(number);
}