* @return the combined URI
*/
public static URI combine(URI prefix, URI suffix) {
- URI retUri = null;
+ URI retUri;
try {
retUri = new URI(combine(prefix.getPath(), suffix.getPath()));
} catch (URISyntaxException e) {
*/
public static URI toURI(String value) throws URISyntaxException {
//5. Convert all back slashes to forward slashes
- if (value.indexOf("\\") != -1) {
+ if (value.contains("\\")) {
value = value.replace('\\', '/');
}
import org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException;
import org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException;
-import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.openxml4j.opc.PackageRelationshipTypes;
import org.apache.poi.openxml4j.opc.ZipPackage;
import org.apache.poi.openxml4j.util.ZipSecureFile.ThresholdInputStream;
import org.apache.poi.poifs.filesystem.FileMagic;
import org.apache.poi.util.Internal;
-import org.apache.poi.util.Removal;
@Internal
public final class ZipHelper {
/**
* Retrieve the zip entry of the core properties part.
*
- * @throws OpenXML4JException
- * Throws if internal error occurs.
+ * @throws IllegalArgumentException If the relationship for
+ * core properties cannot be read or an invalid name is
+ * specified in the properties.
*/
public static ZipEntry getCorePropertiesZipEntry(ZipPackage pkg) {
PackageRelationship corePropsRel = pkg.getRelationshipsByType(
}
// Peek at the first few bytes to sanity check
- FileInputStream input = new FileInputStream(file);
- try {
+ try (FileInputStream input = new FileInputStream(file)) {
verifyZipHeader(input);
- } finally {
- input.close();
}
// Open as a proper zip file
for (IBodyElement e : fn.getBodyElements()) {
if (e instanceof XWPFParagraph) {
String txt = ((XWPFParagraph) e).getText();
- if (txt.indexOf("Footnote_sdt") > -1) {
+ if (txt.contains("Footnote_sdt")) {
hits++;
}
}
@Test
public void testSetFont() {
- Font f = new Font("Helvetica", 0, 12);
+ Font f = new Font("Helvetica", Font.PLAIN, 12);
graphics.setFont(f);
assertEquals(f, graphics.getFont());
}
private boolean isDialogPresent() {
String fontDebugStr = graphics.getFont().toString();
- return fontDebugStr.indexOf("dialog") != -1 || fontDebugStr.indexOf("Dialog") != -1;
+ return fontDebugStr.contains("dialog") || fontDebugStr.contains("Dialog");
}
@Test
evaluator.evaluateFormulaCell(lA1Cell);
fail("Missing external workbook reference exception expected!");
}catch(RuntimeException re) {
- assertTrue("Unexpected exception: " + re, re.getMessage().indexOf(SOURCE_DUMMY_WORKBOOK_FILENAME) != -1);
+ assertTrue("Unexpected exception: " + re, re.getMessage().contains(SOURCE_DUMMY_WORKBOOK_FILENAME));
}
}