解决编译warning
This commit is contained in:
@ -14,6 +14,7 @@ package org.artofsolving.jodconverter.cli;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
@ -86,7 +87,7 @@ public class Convert {
|
||||
DocumentFormatRegistry registry;
|
||||
if (commandLine.hasOption(OPTION_REGISTRY.getOpt())) {
|
||||
File registryFile = new File(commandLine.getOptionValue(OPTION_REGISTRY.getOpt()));
|
||||
registry = new JsonDocumentFormatRegistry(FileUtils.readFileToString(registryFile));
|
||||
registry = new JsonDocumentFormatRegistry(FileUtils.readFileToString(registryFile, Charset.defaultCharset()));
|
||||
} else {
|
||||
registry = new DefaultDocumentFormatRegistry();
|
||||
}
|
||||
@ -122,5 +123,5 @@ public class Convert {
|
||||
officeManager.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ package org.artofsolving.jodconverter.document;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -25,7 +26,7 @@ import org.json.JSONObject;
|
||||
public class JsonDocumentFormatRegistry extends SimpleDocumentFormatRegistry {
|
||||
|
||||
public JsonDocumentFormatRegistry(InputStream input) throws JSONException, IOException {
|
||||
readJsonArray(IOUtils.toString(input));
|
||||
readJsonArray(IOUtils.toString(input, Charset.defaultCharset()));
|
||||
}
|
||||
|
||||
public JsonDocumentFormatRegistry(String source) throws JSONException {
|
||||
|
||||
@ -15,7 +15,7 @@ public class FileProperties {
|
||||
}
|
||||
|
||||
public Map<String, Object> toMap() {
|
||||
Map<String, Object> map = new HashMap();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (filePassword != null) {
|
||||
map.put("Password", filePassword);
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ import static org.artofsolving.jodconverter.process.ProcessManager.PID_NOT_FOUND
|
||||
import static org.artofsolving.jodconverter.process.ProcessManager.PID_UNKNOWN;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -134,11 +135,11 @@ class OfficeProcess {
|
||||
logger.fine("no %OFFICE_HOME%/basis-link found; assuming it's OOo 2.x and we don't need to append URE and Basic paths");
|
||||
return;
|
||||
}
|
||||
String basisLinkText = FileUtils.readFileToString(basisLink).trim();
|
||||
String basisLinkText = FileUtils.readFileToString(basisLink, Charset.defaultCharset()).trim();
|
||||
File basisHome = new File(officeHome, basisLinkText);
|
||||
File basisProgram = new File(basisHome, "program");
|
||||
File ureLink = new File(basisHome, "ure-link");
|
||||
String ureLinkText = FileUtils.readFileToString(ureLink).trim();
|
||||
String ureLinkText = FileUtils.readFileToString(ureLink, Charset.defaultCharset()).trim();
|
||||
File ureHome = new File(basisHome, ureLinkText);
|
||||
File ureBin = new File(ureHome, "bin");
|
||||
Map<String,String> environment = processBuilder.environment();
|
||||
@ -163,9 +164,9 @@ class OfficeProcess {
|
||||
}
|
||||
|
||||
private class ExitCodeRetryable extends Retryable {
|
||||
|
||||
|
||||
private int exitCode;
|
||||
|
||||
|
||||
protected void attempt() throws TemporaryException, Exception {
|
||||
try {
|
||||
exitCode = process.exitValue();
|
||||
@ -173,7 +174,7 @@ class OfficeProcess {
|
||||
throw new TemporaryException(illegalThreadStateException);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getExitCode() {
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
package org.artofsolving.jodconverter.process;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -25,11 +26,10 @@ import org.apache.commons.io.IOUtils;
|
||||
* <p>
|
||||
* Should Work on Solaris too, except that the command line string
|
||||
* returned by <tt>ps</tt> there is limited to 80 characters and this affects
|
||||
* {@link #findPid(String)}.
|
||||
*/
|
||||
public class LinuxProcessManager implements ProcessManager {
|
||||
|
||||
private static final Pattern PS_OUTPUT_LINE = Pattern.compile("^\\s*(\\d+)\\s+(.*)$");
|
||||
private static final Pattern PS_OUTPUT_LINE = Pattern.compile("^\\s*(\\d+)\\s+(.*)$");
|
||||
|
||||
private String[] runAsArgs;
|
||||
|
||||
@ -74,9 +74,7 @@ public class LinuxProcessManager implements ProcessManager {
|
||||
command = args;
|
||||
}
|
||||
Process process = new ProcessBuilder(command).start();
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> lines = IOUtils.readLines(process.getInputStream());
|
||||
return lines;
|
||||
return IOUtils.readLines(process.getInputStream(), Charset.defaultCharset());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user