【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《java代码生成器》,欢迎阅读!
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. * @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 FileOutputStream("c:\\temp\\test.html");
21. osw = new OutputStreamWriter(os,"UTF-8"); 22. bw = new BufferedWriter(osw); 23. bw.write("\r\n"); 24. bw.write("\r\n");
25. bw.write("=\"text/html; charset=UTF-8\">\r\n");
26. bw.write("文本测试\r\n"); 27. createScript(bw);
28. bw.write("\r\n");
29. bw.write("\r\n"); 30. createTable(bw);
31. bw.write("\r\n"); 32. bw.write("\r\n"); 33. bw.flush();
34. }catch(Exception e){ 35. e.printStackTrace(); 36. }finally{
37. try {
38. bw.close();
39. } catch (IOException e) { 40. e.printStackTrace(); 41. } 42. try {
43. osw.close();
44. } catch (IOException e) { 45. e.printStackTrace(); 46. } 47. try {
48. os.close();
49. } catch (IOException e) { 50. e.printStackTrace(); 51. } 52. } 53. 54. }
55. public static void createScript(BufferedWriter bw) throws IOException{
56. bw.write("\r\n"); 61. } 62.
63. public static void createTable(BufferedWriter bw) throws IOException{
64. bw.write("ding=\"0\">\r\n");
65. bw.write("\r\n"); 66. for(int j=0;j<5;j++){
67. bw.write("列"+j+" | \r\n"); 68. }
69. bw.write("
\r\n"); 70. for(int i=0;i<10;i++){ 71. bw.write("\r\n"); 72. for(int j=0;j<5;j++){
73. bw.write(""+j+" | \r\n"); 74. }
75. bw.write("
\r\n"); 76. }
77. bw.write("
\r\n");
78. } 79.
80. public static void main(String[] args){ 81. createHtml(); 82. } 83. 84.}
本文来源:https://www.wddqxz.cn/ac223a4dc850ad02de80418f.html