Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed resource leak #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,41 @@
public class EMFDump {

public static void main(String[] args) {
FileInputStream fis = null;
EMFInputStream emf = null;

try {
FileInputStream fis = new FileInputStream(args[0]);
EMFInputStream emf = new EMFInputStream(fis);

long start = System.currentTimeMillis();
EMFHeader header = emf.readHeader();
System.out.println(header);

Tag tag = emf.readTag();
while (tag != null) {
System.out.println(tag);
tag = emf.readTag();
}
System.out.println("Parsed file in: "
+ (System.currentTimeMillis() - start) + " ms.");
} catch (IOException e) {
e.printStackTrace();
}
try {
fis = new FileInputStream(args[0]);
emf = new EMFInputStream(fis);

long start = System.currentTimeMillis();
EMFHeader header = emf.readHeader();
System.out.println(header);

Tag tag = null;
do {
tag = emf.readTag();
System.out.println(tag);

if (tag instanceof EOF) {
// stop on End Of File tag
break;
}
} while (tag != null);

System.out.println("Parsed file in: " + (System.currentTimeMillis() - start) + " ms.");
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (null != emf) {
emf.close();
} else if (null != fis) {
fis.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}