使用DataOutputStream将int写入文件
import java.io.DataOutputStream; import java.io.FileOutputStream; import java.io.IOException;/**来自 NowJava.com - 时 代 Java**/ public class Main { public static void main(String[] args) { String strFilePath = "C://Folder//WriteInt.txt"; try { FileOutputStream fos = new FileOutputStream(strFilePath); DataOutputStream dos = new DataOutputStream(fos); int i = 100; //N o w J a v a . c o m 提供 dos.writeInt(i); dos.close();