Monthly Archives: 12月 2012

java.io.FileOutputStream.FileOutputStream()の使い方

サンプルコード
package com.arkgame.study;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class FileOutputStreamDemo {

public static void main(String[] args) {
String fileName = “D:\\soft” + File.separator + “world.txt”;
File f = new File(fileName);
OutputStream out;
try {
out = new FileOutputStream(f);
String str = “test data”;
byte[] b = str.getBytes();
out.write(b);
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {

e.printStackTrace();
}

}

}