通过以下代码将不需要的字符添加到文本文件中的单词中。请帮助我如何解决它。
try
{
Fout = new FileOutputStream("C:/IBM/omnibus.txt",true);
dos = new DataOutputStream(Fout);
{
dos.writeUTF(SitName.getText().toString() + "\t");
dos.writeUTF(TTGrp.getText().trim() + "\t");
dos.writeUTF(EmailGrp.getText().trim() + "\t");
if(chkAlertY.isSelected())
dos.writeUTF("1 \t");
if(chkAlertN.isSelected())
dos.writeUTF("0 \t");
if(chkSmsY.isSelected())
dos.writeUTF("1 \t");
if(chkSmsN.isSelected())
dos.writeUTF("0 \t");
if(chkEmailY.isSelected())
dos.writeUTF("1 \n");
if(chkEmailN.isSelected())
dos.writeUTF("0 \n");
Fout.close();
}
输出>>
abc NULETXdef NUL ETXghi 1
新代码
try
{
FileWriter file = new FileWriter ("C:/IBM/omnibus.txt",true);
BufferedWriter dos = new BufferedWriter(file);
dos.write(SitName.getText().toString() + "\t");
dos.write(TTGrp.getText().trim() + "\t");
dos.write(EmailGrp.getText().trim() + "\t");
if(chkAlertY.isSelected())
dos.write("1 \t");
if(chkAlertN.isSelected())
dos.write("0 \t");
if(chkSmsY.isSelected())
dos.write("1 \t");
if(chkSmsN.isSelected())
dos.write("0 \t");
if(chkEmailY.isSelected())
dos.write("1 \n");
if(chkEmailN.isSelected())
dos.write("0 \n");
file.close();
}
catch(Exception e)
{
System.out.println("The Exception Is : " +e);
}
}