public class Demo {
public static void main(String[] args) {
try {
OutputStream out = new FileOutputStream("D:\\java.txt");
/*File file = new File("D:\\java.txt");
OutputStream out2 = new FileOutputStream(file);*/
out.write(97);
out.write(98);
byte[] byteArray = {97,98,99,100};
out.write(byteArray);
String str = "我爱Java";
byteArray = str.getBytes();
out.write(str.getBytes());
out.write(byteArray,2,2
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} |
|