7efe609b538876fc3cac2c10112545042f2c3d61.svn-base 704 B

123456789101112131415161718192021222324252627
  1. package com.toolkit.file.encode.frame.filetoUtf8;
  2. import java.io.File;
  3. import java.io.FileNotFoundException;
  4. import java.io.FileOutputStream;
  5. import java.io.IOException;
  6. import java.io.OutputStreamWriter;
  7. public class CreateUTF8File{
  8. public void create(String outPath, String content) {
  9. try {
  10. File out = new File(outPath);
  11. FileOutputStream outFile = new FileOutputStream(out);
  12. OutputStreamWriter writer = new OutputStreamWriter(outFile, "UTF–8");
  13. writer.write(content);
  14. writer.close();
  15. outFile.close();
  16. out = null;
  17. } catch (FileNotFoundException e) {
  18. System.out.println(e.getMessage());
  19. } catch (IOException ioEx) {
  20. System.out.println(ioEx.getMessage());
  21. }
  22. }
  23. }