Fix one more place where stream were left open when an exception is thrown
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1753123 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
da595c2343
commit
da9cd94e76
@ -57,15 +57,13 @@ public class FormulaViewer
|
|||||||
*/
|
*/
|
||||||
public void run() throws IOException {
|
public void run() throws IOException {
|
||||||
NPOIFSFileSystem fs = new NPOIFSFileSystem(new File(file), true);
|
NPOIFSFileSystem fs = new NPOIFSFileSystem(new File(file), true);
|
||||||
|
try {
|
||||||
InputStream is = BiffViewer.getPOIFSInputStream(fs);
|
InputStream is = BiffViewer.getPOIFSInputStream(fs);
|
||||||
|
try {
|
||||||
List<Record> records = RecordFactory.createRecords(is);
|
List<Record> records = RecordFactory.createRecords(is);
|
||||||
|
|
||||||
for (int k = 0; k < records.size(); k++)
|
for (Record record : records) {
|
||||||
{
|
if (record.getSid() == FormulaRecord.sid) {
|
||||||
Record record = records.get(k);
|
|
||||||
|
|
||||||
if (record.getSid() == FormulaRecord.sid)
|
|
||||||
{
|
|
||||||
if (list) {
|
if (list) {
|
||||||
listFormula((FormulaRecord) record);
|
listFormula((FormulaRecord) record);
|
||||||
} else {
|
} else {
|
||||||
@ -73,9 +71,13 @@ public class FormulaViewer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
is.close();
|
is.close();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
fs.close();
|
fs.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void listFormula(FormulaRecord record) {
|
private void listFormula(FormulaRecord record) {
|
||||||
String sep="~";
|
String sep="~";
|
||||||
@ -90,7 +92,7 @@ public class FormulaViewer
|
|||||||
numArg = String.valueOf(-1);
|
numArg = String.valueOf(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuilder buf = new StringBuilder();
|
||||||
|
|
||||||
if (token instanceof ExpPtg) return;
|
if (token instanceof ExpPtg) return;
|
||||||
buf.append(token.toFormulaString());
|
buf.append(token.toFormulaString());
|
||||||
@ -154,7 +156,7 @@ public class FormulaViewer
|
|||||||
|
|
||||||
private String formulaString(FormulaRecord record) {
|
private String formulaString(FormulaRecord record) {
|
||||||
|
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuilder buf = new StringBuilder();
|
||||||
Ptg[] tokens = record.getParsedExpression();
|
Ptg[] tokens = record.getParsedExpression();
|
||||||
for (Ptg token : tokens) {
|
for (Ptg token : tokens) {
|
||||||
buf.append( token.toFormulaString());
|
buf.append( token.toFormulaString());
|
||||||
|
Loading…
Reference in New Issue
Block a user