假设我有这种文件
SCHEDULE AEP#GSAE3_SCO_D99008 TIMEZONE ECT
DESCRIPTION "APOLLO_ MQFT SENDING JOBS"
ON RUNCYCLE RULE1 "FREQ=DAILY;"
:
AEP#GSAE3_SCO_D99008_ASUP_ORD_V4
SCRIPTNAME "-job Z3_SCO_D99008_ASUP_ORD_V4 -user BECKDEL1 -i 04093800 -c C"
STREAMLOGON batchatl
DESCRIPTION "Take Customer Order to be send in MQFT format"
TASKTYPE SAP
RECOVERY STOP
AT 2145 TIMEZONE ECT
NEEDS 1 AEP#GSAE_SCO
...
END
这是来自TWS(Tivoli Workload Scheduler)的文件。我想得到的是JSON或XML文件:
{
"Jobstream":"AEP#GSAE3_SCO_D99008",
"Timezone": "ECT",
"Description": "APOLLO_ MQFT SENDING JOBS",
"Jobs": {[
"Job": "AEP#GSAE3_SCO_D99008_ASUP_ORD_V4",
"SAP_JOB": "Z3_SCO_D99008_ASUP_ORD_V4",
"SAP_USER": "BECKDEL1",
"Id": 04093800,
"Streamlogon": "batchatl",
"Description": "Take Customer Order to be send in MQFT format",
"Tasktype": "SAP",
"Recovery": "STOP",
"AT": 2145,
"TIMEZONE": "ECT"
],[...]}
我需要阅读以了解如何解析此类文件? 我尝试在Java中使用BufferReader和Scanner。 我已经有2个Java类:JobStream和Job。 作业流:
public class Jobstream {
private String name;
private String timeZone;
private String description;
private ArrayList<Job> jobs;
public Jobstream(String name, String timeZone, String description) {
this.name = name;
this.timeZone = timeZone;
this.description = description;
this.jobs = new ArrayList<>();
}
public void appendJob(Job job) {
this.jobs.add(job);
}
}
和工作:
public class Job {
private String name;
private String sapName;
private String sapUser;
private int id;
private String logon;
private String description;
private String type;
private String recovery;
private int at;
private String timezone;
public Job(String name, String sapName, String sapUser,
int id, String logon, String description,
String type, String recovery, int at, String timezone) {
this.name = name;
this.sapName = sapName;
this.sapUser = sapUser;
this.id = id;
this.logon = logon;
this.description = description;
this.type = type;
this.recovery = recovery;
this.at = at;
this.timezone = timezone;
}
}
这就是结构。
如果你告诉我我的方式,它会很棒。
度过美好的一天!
P.S。我不是要求帮我写一个解析器。我只是想帮助我找到我需要由MYSELF编写的信息。