字符流与字节流
8、
package com.yootk.demo;
import java.io.*;
public class YootkDemo {
public static void main(String[] args) throws Exception {
File file = new File("H:" + File.separator + "muyan" + File.separator + "vip" + File.separator + "yootk.txt") ;
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs() ;
}
OutputStream output = new FileOutputStream(file) ;
String message = "www.yootk.com" ;
byte data [] = message.getBytes() ;
output.write(data);
}
}
9、
package com.yootk.demo;
import java.io.*;
public class YootkDemo {
public static void main(String[] args) throws Exception {
File file = new File("H:" + File.separator + "muyan" + File.separator + "vip" + File.separator + "yootk.txt") ;
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs() ;
}
Writer out = new FileWriter(file) ;
String message = "www.yootk.com" ;
out.write(message);
}
}
10、
package com.yootk.demo;
import java.io.*;
public class YootkDemo {
public static void main(String[] args) throws Exception {
File file = new File("H:" + File.separator + "muyan" + File.separator + "vip" + File.separator + "yootk.txt") ;
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs() ;
}
Writer out = new FileWriter(file) ;
String message = "www.yootk.com\n" ;
out.write(message);
out.append("edu.yootk.com") ;
out.flush();
}
}