正常に動作していますが、データを1行ずつ書き込む必要があります。arraylis オブジェクトから 1 つのデータを取得し、信号線をテキスト ファイルに書き込みたいと考えています。2 番目のオブジェクトは次の行に来る必要があります。
public void writeFile() {
FileWriter writer = null;
try {
writer = new FileWriter("E:/AutomationToolWorkplace/AutomationTool/Test/ExpectedOutputHomescreenModule1.txt");
for (String str : MP_result_set) {
System.out.println("");
writer.write(str);
}
writer.close();
} catch (IOException ex) {
Logger.getLogger(Transciever.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
writer.close();
} catch (IOException ex) {
Logger.getLogger(Transciever.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
出力:
{"data":
{"shared":false,
"port":"4096",
"packageName":"",
"installed":false,
"lock":false,
"like":false,
"type":"HomeScreen",
"ip":"192.168.1.24",
"screenId":"9999",
"selected":false,
"category":"",
"servicetype":"",
"price":"",
"subscribe":false,
"event":false,
"subtype":"Recommended",
"predefined":false,
"pricingmodel":"PPC",
"packageSelected":false}}
{"data":{
"port":"4096",
"screenId":"2050",
"result":"failure",
"recordList":[],
"reminderList":[],
"msg":"No record",
"playList":[],
"ip":"192.168.1.24"}}
{"data":{
"port":"4096",
"screenId":"12105",
"result":"success",
"list":["music","Action","Romance","Horror","Comedy","Thriller","Mystery","Drama"],
"type":"genre",
"ip":"192.168.1.24"}}