最近遇到个错误,先粘贴代码如下:
功能大致如下:
先指定一个路径的文件,如果文件不存在,则创建,如果存在,则清空文件内容。然后再写内容。
File xmlFile = new File("D:/Users/Administrator/workspace/CDMS/temp/");
if (!()) {
// 没有文件则创建
();
} else {
// 有文件则清空文件内容
FileWriter fw = new FileWriter(xmlFile);
("");
();
}
// File xmlFile = ();
try {
InputStream is = new FileInputStream(xmlFile);
byte[] bytes = new byte[100];
String xmlStr = "";
int temp;
while ((temp = (bytes)) != -1) {
xmlStr += new String(bytes, 0, temp);
}
错误信息如下:
信息: Reloading Context with name [/CDMS] is completed
- with linked exception:
[; lineNumber: 1; columnNumber: 1; 文件提前结束。]
at (:335)
at .(:563)
at ..unmarshal0(:249)
at .(:214)
at (:157)
at (:214)
at .xml2Java(:37)
at (:130)
at .invoke0(Native Method)
at (:62)
at (:43)
at (:498)
at .(:441)
at .(:280)
at .(:243)
at .(:165)
at .(:87)
at .(:237)
at .(:252)
at .(:68)
at .(:87)
at .(:237)
at .(:122)
at .(:237)
at .(:195)
at .(:87)
at .(:237)
at .(:195)
at .(:87)
at .(:237)
at .(:179)
at .(:237)
at .(:75)
at .(:237)
at .(:94)
at .(:237)
at .(:235)
at .(:237)
at .(:89)
at .(:237)
at .(:130)
at .(:237)
at .(:267)
at .(:237)
at .(:126)
at .(:237)
at .(:138)
at .(:87)
at .(:237)
at ..(:165)
at .(:237)
at .(:164)
at .(:237)
at .(:179)
at .(:237)
at .(:176)
at .(:237)
at .(:52)
at .(:488)
at .(:77)
at .(:91)
at (:240)
at (:207)
at (:212)
at (:106)
at (:502)
at (:141)
at (:79)
at (:616)
at (:88)
at (:522)
at .http11.(:1095)
at $(:672)
at $(:1502)
at $(:1458)
at (:1142)
at $(:617)
at $(:61)
at (:745)