package j2se;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class TestIoWrite {
public static void main(String[] args) {
String xml = "";
byte[] bytexml = xml.getBytes();
try {
OutputStream os = new FileOutputStream(new File("c:/1.xml"));
os.write(bytexml);
os.flush();
os.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static void writeStrToFile(String xml){
try {
FileOutputStream fos = new FileOutputStream(new File(System.getProperty("user.dir")+"\\WebRoot\\xml_format_file.xml"));
Writer os = new OutputStreamWriter(fos, "GBK");
os.write(xml);
os.flush();
fos.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}