资源描述:
《java代码生成器》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Java实现的代码生成器·Java实用程序总结Java代码1.package test; 2. 3.import java.io.BufferedWriter; 4.import java.io.FileOutputStream; 5.import java.io.IOException; 6.import java.io.OutputStream; 7.import java.io.OutputStreamWriter; 8./** 9. * 代码生成器 10. * @author penghuaiyi 11.
2、* @date 2011-09-09 12. */ 13.public class CodeUtil { 14. 15. public static void createHtml(){ 16. OutputStream os = null; 17. OutputStreamWriter osw = null; 18. BufferedWriter bw = null; 19. try{ 20. os = new FileOutp
3、utStream("c:\temp\test.html"); 21. osw = new OutputStreamWriter(os,"UTF-8"); 22. bw = new BufferedWriter(osw); 23. bw.write("r"); 24. bw.write("
r"); 25. bw.write("
4、nt-Type" content="text/html; charset=UTF-8">r"); 26. bw.write("
文本测试r"); 27. createScript(bw); 28. bw.write("r"); 29. bw.write("r"); 30. createTabl
5、e(bw); 31. bw.write("r"); 32. bw.write("r"); 33. bw.flush(); 1. }catch(Exception e){ 2. e.printStackTrace(); 3. }finally{ 4. try { 5. bw.close(); 6.
6、 } catch (IOException e) { 7. e.printStackTrace(); 8. } 9. try { 10. osw.close(); 11. } catch (IOException e) { 12. e.printStackTrace(); 13. } 14. try {
7、15. os.close(); 16. } catch (IOException e) { 17. e.printStackTrace(); 18. } 19. } 20. 21. } 22. public static void createScript(BufferedWriter bw) throws IOException{ 23. bw.writ
8、e("