我想把读取.txt后这些数据,输出到execl中,这是两个程序,如何让他们组合到一起,然后实现读取后就输出呢,要是能帮我加一个读取这个.txt文本后,遍历里面的程序做匹配对应,是最好的,麻烦大神们了
附上的代码如下:读取的代码
public class demo{
/**
* 管理后台获取后台数据
* begin
* @throws WriteException
*/
public static void main(String[] args) {
String json_jiade = readFile("D:\\111.txt");
System.out.println("去掉注释前:");
System.out.println(json_jiade);
String str = json_jiade.replaceAll("[#].*", "");
System.out.println("去掉注释后:");
System.out.println(str);
}
/**读取本地文件
* @param remoteFile
* @return
*/
public static String readFile(String remoteFile) {
String log = "";
try {
File file = new File(remoteFile);
FileInputStream is = new FileInputStream(remoteFile);
int size = (int) file.length();
byte[] bytes = getBytes(is,size);
String content = new String(bytes, "UTF-8");
log = content;
is.close();
} catch (IOException ex) {
}
return log;
}
private static byte[] getBytes(InputStream inputStream,int size) {
byte[] bytes = new byte[size];
try {
int readBytes = inputStream.read(bytes);
return bytes;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
哪位大神可以帮我组合好,发给我,不胜感谢