Revision 8298
Added by Matt Jones about 11 years ago
src/edu/ucsb/nceas/metacat/DocumentImpl.java | ||
---|---|---|
1527 | 1527 |
&& (FileUtil.getFileStatus(documentPath) == FileUtil.DOES_NOT_EXIST |
1528 | 1528 |
|| FileUtil.getFileSize(documentPath) == 0)) { |
1529 | 1529 |
|
1530 |
try |
|
1531 |
{ |
|
1532 |
|
|
1533 |
FileOutputStream fos = new FileOutputStream(documentPath); |
|
1534 |
IOUtils.write(xml.getBytes(encoding), fos); |
|
1535 |
|
|
1536 |
fos.flush(); |
|
1537 |
fos.close(); |
|
1538 |
} |
|
1539 |
catch(IOException ioe) |
|
1540 |
{ |
|
1541 |
throw new McdbException("Could not write file: " + documentPath + " : " |
|
1542 |
+ ioe.getMessage()); |
|
1543 |
} |
|
1530 |
FileOutputStream fos = null; |
|
1531 |
try { |
|
1532 |
fos = new FileOutputStream(documentPath); |
|
1533 |
IOUtils.write(xml.getBytes(encoding), fos); |
|
1534 |
|
|
1535 |
fos.flush(); |
|
1536 |
fos.close(); |
|
1537 |
fos = null; |
|
1538 |
} catch (IOException ioe) { |
|
1539 |
throw new McdbException("Could not write file: " + documentPath + " : " + ioe.getMessage()); |
|
1540 |
} finally { |
|
1541 |
if (fos != null) { |
|
1542 |
try { |
|
1543 |
fos.close(); |
|
1544 |
} catch (IOException ioe) { |
|
1545 |
// Do nothing |
|
1546 |
} |
|
1547 |
} |
|
1548 |
} |
|
1544 | 1549 |
} |
1545 | 1550 |
|
1546 | 1551 |
} catch (PropertyNotFoundException pnfe) { |
Also available in: Unified diff
Added close() to finally block for readFromFileSystem() call.