
de.devsurf.components.converter.openoffice.OOoUtil Maven / Gradle / Ivy
The newest version!
/**
* Copyright (C) 2010 Daniel Manzke
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.devsurf.components.converter.openoffice;
import java.io.IOException;
import org.artofsolving.jodconverter.process.MacProcessManager;
import org.artofsolving.jodconverter.process.ProcessManager;
import org.artofsolving.jodconverter.process.UnixProcessManager;
import org.artofsolving.jodconverter.process.WindowsProcessManager;
import org.artofsolving.jodconverter.util.PlatformUtils;
import de.devsurf.components.converter.UnsupportedFeatureException;
public class OOoUtil {
public static ProcessManager processManager;
public static void kill(String processRegex) throws IOException, UnsupportedFeatureException{
if(processManager == null){
if (PlatformUtils.isLinux()) {
processManager = new UnixProcessManager();
} else if (PlatformUtils.isMac()) {
processManager = new MacProcessManager();
} else if (PlatformUtils.isWindows()) {
WindowsProcessManager windowsProcessManager = new WindowsProcessManager();
processManager = windowsProcessManager.isUsable() ? windowsProcessManager : null;
} else {
processManager = null;
}
}
if(processManager == null)
throw new UnsupportedFeatureException("Not supported by ProcessManager");
String pid = processManager.findPid(processRegex);
if(pid != null){
try {
processManager.kill(null, pid);
} catch (IOException ioe) {
//ignore
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy