java读取txt文件内容

File file = new File(this.getClass().getResource("").getPath());
System.out.println(file.getPath());
String path=file.getPath();
//path=path.substring(0,path.indexOf("WEB-INF"))+"upload\\Excel"+"\\"+"import.txt"; //服务器专用
path=path.substring(0,path.indexOf("target"))+"src\\main\\webapp\\upload\\Excel"+"\\"+"import.txt";
String info=(sqlserver.readFile(path));
info=info.replaceAll("\r|\n", "");
info=info.substring(0,info.length()-1);
String info1[]=info.split("-");
String ip=DesUtil.decrypt(info1[0]);
String databaseName=DesUtil.decrypt(info1[1]);
String usename=DesUtil.decrypt(info1[2]);
String password=DesUtil.decrypt(info1[3]);

猜你喜欢

转载自www.cnblogs.com/dawn-and-night/p/11127173.html