将文本写入html文件类型

Ker*_*y G 2 java webpage file

我试图将以下方法的结果写入网页.我认为这是可能的,我只是在弄清楚究竟该怎么做.任何帮助将非常感激.谢谢.

...
      System.out.println("Final Register");
      for (int i=0; i < ch.length; i++)
        {
         System.out.println(cd.getDenomLiteralAt(i)+" "+cd.getDenomNumAt(i));
        }
   }

...
Run Code Online (Sandbox Code Playgroud)

MaV*_*SCy 5

在java中,有很多方法可以在文件上写入数据.要编写文本数据,最简单的方法是使用BufferedWriter.

见下面的演示

FileWriter fWriter = null;
BufferedWriter writer = null;
try {
    fWriter = new FileWriter("fileName.html");
    writer = new BufferedWriter(fWriter);
    writer.write("<span>This iss your html content here</span>");
    writer.newLine(); //this is not actually needed for html files - can make your code more readable though 
    writer.close(); //make sure you close the writer object 
} catch (Exception e) {
  //catch any exceptions here
}
Run Code Online (Sandbox Code Playgroud)