java怎么对已有文字的txt或word文件进行排版?帮我写个代码
{"code":"m0001","data":[{"bgurl":"","date":"","departmentname":"集团总部-信息管理中心-产品部-培优组",...
{"code":"m0001","data":[{"bgurl":"","date":"","departmentname":"集团总部-信息管理中心-产品部-培优组","email":"zhangyongli@xueersi.com","empno":"003220","hrmImage":"http:\/\/59.151.109.79\/messager\/images\/icon_m.jpg","jobtitlename":"集团总部信息管理中心产品部培优组产品经理","lastname":"张永利","locationid":"","mobilecall":"","pinyinlastname":"","remark":"","requestid":"","sex":"男","telephone":"","userid":"238","userimage":"","username":"","workcode":"003220","workroom":""},{"bgurl":"","date":"","departmentname":"集团总部-信息管理中心-产品部-培优组","email":"yangwentao@xueersi.com","empno":"004733","hrmImage":"http:\/\/59.151.109.79\/messager\/images\/icon_m.jpg","jobtitlename":"集团总部信息管理中心产品部培优组产品专员","lastname":"杨文韬","locationid":"","mobilecall":"","pinyinlastname":"","remark":"","requestid":"","sex":"男","telephone":"","userid":"239","userimage":"","username":"","workcode":"004733","workroom":""}],"message":"获取用户列表成功","result":true}
如这样一长传文字,我想把他变我希望的格式排序。
比如{" 换行
":" 变成== 帮我写个代码谢谢,约简单越好,顺便帮我加个注释更好。 展开
如这样一长传文字,我想把他变我希望的格式排序。
比如{" 换行
":" 变成== 帮我写个代码谢谢,约简单越好,顺便帮我加个注释更好。 展开
1个回答
展开全部
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
public class TestMainArgs {
public static void main(String[] args) throws IOException {
String fileName = "D:" + File.separator + "a.txt";//将要转换格式的文本放到a.txt,放在D盘下,取得路径
File f = new File(fileName);
InputStream in=new FileInputStream(f);
byte[] b=new byte[(int)f.length()];
in.read(b);
in.close();
String str=new String(b);//
System.out.println("原文: "+str);
System.out.println("格式化后: "+str.replace("{\"", "\n").replace("\":\"", "==")); //替换{"为换行,替换":"为== ,要格式化其他的,在str.replace("{\"", "\n").replace("\":\"", "==")添加
}
}
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
public class TestMainArgs {
public static void main(String[] args) throws IOException {
String fileName = "D:" + File.separator + "a.txt";//将要转换格式的文本放到a.txt,放在D盘下,取得路径
File f = new File(fileName);
InputStream in=new FileInputStream(f);
byte[] b=new byte[(int)f.length()];
in.read(b);
in.close();
String str=new String(b);//
System.out.println("原文: "+str);
System.out.println("格式化后: "+str.replace("{\"", "\n").replace("\":\"", "==")); //替换{"为换行,替换":"为== ,要格式化其他的,在str.replace("{\"", "\n").replace("\":\"", "==")添加
}
}
博思aippt
2024-07-20 广告
2024-07-20 广告
作为深圳市博思云创科技有限公司的工作人员,对于Word文档生成PPT的操作,我们有以下建议:1. 使用另存为功能:在Word中编辑完文档后,点击文件->另存为,选择PowerPoint演示文稿(*.pptx)格式,即可将文档内容转换为PPT...
点击进入详情页
本回答由博思aippt提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询