Skip to content
This repository was archived by the owner on Dec 30, 2018. It is now read-only.
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
26 changes: 16 additions & 10 deletions odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfPackage.java
Original file line number Diff line number Diff line change
Expand Up @@ -1585,16 +1585,22 @@ public Document getDom(String internalPath) throws SAXException, ParserConfigura
* @throws java.lang.Exception In case the file could not be saved
*/
public void insert(URI sourceURI, String internalPath, String mediaType) throws Exception {
InputStream is = null;
if (sourceURI.isAbsolute()) {
// if the URI is absolute it can be converted to URL
is = sourceURI.toURL().openStream();
} else {
// otherwise create a file class to open the stream
is = new FileInputStream(sourceURI.toString());
}
insert(is, internalPath, mediaType);
}
InputStream is = null;
try {
if (sourceURI.isAbsolute()) {
// if the URI is absolute it can be converted to URL
is = sourceURI.toURL().openStream();
} else {
// otherwise create a file class to open the stream
is = new FileInputStream(sourceURI.toString());
}
insert(is, internalPath, mediaType);
} finally {
if (is != null) {
is.close();
}
}
}

/**
* Inserts InputStream into an OdfPackage. An existing file will be replaced.
Expand Down