我正在尝试借助BufferedReader
读取另一个 texlipse 文件并写入要生成的 texlipse 文件来生成一个 texlipse 文件BufferedWriter
,在此过程中,我BufferedReader
还将打印由控制台读取的内容。在这样做时,我无法读取某些字符,例如\u
, \b
, \v
,并且我不能忽略这些字符,因为我的 texlipse 在编写乳胶代码时需要这些字符。
package jchart2Dt;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
public class practice3 {
public static BufferedWriter bw;
static String sensitivity = "0.556";
static String offset = "0.125";
public static void main(String[]args) throws NullPointerException{
String pathname = "D:\\Messdaten\\CalibrationCertificate\\document.tex";
File file = new File(pathname);
InitialiseWriter();
try{
FileReader f = new FileReader(file);
BufferedReader br= new BufferedReader(f);
while(br.readLine()!= null){
String content = br.readLine();
System.out.println(content);
content = check(content);
WriteCertificate(content);
}
bw.close();
f.close();
}catch(Exception e){
e.printStackTrace();
}
}
public static void InitialiseWriter() {
// TODO Auto-generated method stub
File file = new File ("D:\\Messdaten\\CalibrationCertificate\\certificate.tex");
try {
if(!file.exists()){
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile());
bw=new BufferedWriter(fw);
} catch (Exception e) {}
}
public static String check(String line_content) {
String output = line_content.replace("<<sensitivity>>", sensitivity);
output = output.replace("<<offset>>", offset);
return output;
}
public static void WriteCertificate(String content) {
try{
bw.write(content +"\n");
}catch(Exception e){}
}
}