import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class WriteByteStream {
public static void main(String[] args){
try {
FileOutputStream fos = new FileOutputStream("testw.txt");
String outString = "write 12346写出数据";
byte output[] = outString.getBytes("GBK");
fos.write(output);
fos.close();
System.out.println("done");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
|
|