我正在尝试使用简单 XML解析 BART 车站列表,如下所示:https: //api.bart.gov/docs/stn/stns.aspx (链接:http: //simple.sourceforge.net/download /stream/doc/tutorial/tutorial.php)。我已经这样设置了我的反序列化对象:
StationList 对象:
@Root(name = "root")
public class StationList {
@ElementList(name = "stations", inline = true)
private List<Station> stations;
@Element(name = "message", required = false)
private String message;
public StationList() {
}
public List<Station> getStations() {
return stations;
}
public String getMessage() {
return message;
}
}
Run Code Online (Sandbox Code Playgroud)
建站对象:
@Root(name = "station", strict = false)
public class Station {
@Element(name ="name")
private String name;
@Element(name = "abbr")
private String abbr;
@Element(name = "gtfs_latitude") …Run Code Online (Sandbox Code Playgroud) 我有这行代码:
int outputfd = open(charArray[a + 1], O_CREAT| O_WRONLY | O_TRUNC | S_IWUSR, 0640);
Run Code Online (Sandbox Code Playgroud)
我想要打开文件,如果它已经存在,我想创建然后打开,如果它不存在.如果我删除O_CREAT,则只打开现有文件.如果我把它留在里面,我只能创建文件,然后打开它们.
我怎么能两个都做?