本文整理匯總了Java中org.apache.commons.lang3.SystemUtils.IS_OS_LINUX屬性的典型用法代碼示例。如果您正苦於以下問題:Java SystemUtils.IS_OS_LINUX屬性的具體用法?Java SystemUtils.IS_OS_LINUX怎麽用?Java SystemUtils.IS_OS_LINUX使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.apache.commons.lang3.SystemUtils
的用法示例。
在下文中一共展示了SystemUtils.IS_OS_LINUX屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: read
public static void read(File file, Consumer<File> handle) throws IOException {
Path temp;
if (SystemUtils.IS_OS_LINUX) {
temp = Files.createTempFile(SHARED_MEMORY, TEMP_PREFIX, null);
} else {
temp = Files.createTempFile(TEMP_PREFIX, null);
}
try (
InputStream is = new FileInputStream(file);
GZIPInputStream gis = new GZIPInputStream(is);
OutputStream os = Files.newOutputStream(temp);
) {
byte[] buffer = new byte[1024];
int length;
while ((length = gis.read(buffer, 0, 1024)) != -1) {
os.write(buffer, 0, length);
}
handle.accept(temp.toFile());
} finally {
Files.delete(temp);
}
}
示例2: getModules
public List<CarnotzetModule> getModules() {
if (modules == null) {
modules = resolver.resolve(config.getTopLevelModuleId(), failOnDependencyCycle);
if (SystemUtils.IS_OS_LINUX || !getResourcesFolder().resolve("expanded-jars").toFile().exists()) {
resourceManager.extractResources(modules);
modules = computeServiceIds(modules);
resourceManager.resolveResources(modules);
}
log.debug("configuring modules");
modules = configureModules(modules);
if (config.getExtensions() != null) {
for (CarnotzetExtension feature : config.getExtensions()) {
log.debug("Extension [{}] enabled", feature.getClass().getSimpleName());
modules = feature.apply(this);
}
}
assertNoDuplicateArtifactId(modules);
modules = selectModulesForUniqueServiceId(modules);
}
return modules;
}
示例3: getSensor
public static Sensor getSensor() {
if (SystemUtils.IS_OS_WINDOWS) {
return new WindowsSensor();
} else if (SystemUtils.IS_OS_LINUX) {
return new LMSensor();
} else {
System.err.println(SystemUtils.OS_NAME + " is not a supported operating system.");
return new Sensor() {
@Override
public void poll() throws IOException {
temperatures.put("Fake 0", 0d);
temperatures.put("Fake 100", 100d);
}
};
}
}
示例4: init
@PostConstruct
public void init() {
if (SystemUtils.IS_OS_LINUX) {
usersPath = environment.getProperty("image.path.linux.users");
formsPath = environment.getProperty("image.path.linux.forms");
} else if (SystemUtils.IS_OS_MAC) {
usersPath = environment.getProperty("image.path.mac.users");
formsPath = environment.getProperty("image.path.mac.forms");
} else if (SystemUtils.IS_OS_WINDOWS) {
usersPath = environment.getProperty("image.path.windows.users");
formsPath = environment.getProperty("image.path.windows.forms");
}
userContext = environment.getProperty("image.context.user");
formContext = environment.getProperty("image.context.form");
}
示例5: getSteamDir
public static File getSteamDir() throws RegistryException, IOException {
if (null == steamDir) {
if(SystemUtils.IS_OS_WINDOWS) {
steamDir = test(new File(WindowsRegistry.getInstance().readString(HKey.HKCU, "Software\\Valve\\Steam", "SteamPath")));
} else if(SystemUtils.IS_OS_MAC) {
steamDir = test(new File(SystemUtils.getUserHome()+"/Library/Application Support/Steam"));
} else if(SystemUtils.IS_OS_LINUX) {
ArrayList<File> fl = new ArrayList<>();
fl.add(new File(SystemUtils.getUserHome()+"/.steam/steam"));
fl.add(new File(SystemUtils.getUserHome()+"/.steam/Steam"));
fl.add(new File(SystemUtils.getUserHome()+"/.local/share/steam"));
fl.add(new File(SystemUtils.getUserHome()+"/.local/share/Steam"));
steamDir = test(fl);
}
}
return steamDir;
}
示例6: searchContent
@SuppressFBWarnings("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS")
@Test
public void searchContent()
throws ProcessConfigurationException, IOException, InterruptedException,
JsonArrayReaderException {
final Output response =
ProcessRunnerFactory.startProcess(
new ConfigurationBuilder(getDefaultInterpreter(), getInterPreterVersion())
.setWorkigDir(Constants.DEFAULT_CURRENT_DIR_PATH)
.setMasterLogFile(Utilities.createTempLogDump(), true)
.build());
assertThat("Validating process return code : ", response.getReturnCode(), is(0));
if (SystemUtils.IS_OS_LINUX) {
assertThat(
"Validating searchMasterLog result for content in the output in UNIX : ",
response.searchMasterLog(".*GNU.*"),
is(true));
} else if (SystemUtils.IS_OS_WINDOWS) {
assertThat(
"Validating searchMasterLog result for content in the output in Windows : ",
response.searchMasterLog("Microsoft Windows.*"),
is(true));
}
}
示例7: getOs
@Nonnull
public String getOs() {
String result = this.os;
if (isSafeEmpty(result)) {
if (SystemUtils.IS_OS_WINDOWS) {
result = "windows";
} else if (SystemUtils.IS_OS_LINUX) {
result = "linux";
} else if (SystemUtils.IS_OS_FREE_BSD) {
result = "freebsd";
} else {
result = "darwin";
}
}
return result;
}
示例8: getConfigBasePathForAll
/**
* 獲得全平台的基礎路徑<br>
* 真正的跨平台!
* @author Administrator
* @return
*/
public static String getConfigBasePathForAll()
{
String ret = "";
//根據操作係統決定真正的配置路徑
if (SystemUtils.IS_OS_WINDOWS)
{
ret = FileKit.getMyConfigBasePathForWindows();
}
else if (SystemUtils.IS_OS_LINUX)
{
ret = CONFIG_BASEPATH_LINUX;
}
else if (SystemUtils.IS_OS_MAC)
{
ret = CONFIG_BASEPATH_MAC;
}
else
{
//其他情況下,都是類Unix的係統,因此均采用Linux的路徑設置
ret = CONFIG_BASEPATH_LINUX;
}
return ret;
}
示例9: GremlinServer
/**
* Construct a Gremlin Server instance from the {@link ServerGremlinExecutor} which internally carries some
* pre-constructed objects used by the server as well as the {@link Settings} object itself. This constructor
* is useful when Gremlin Server is being used in an embedded style and there is a need to share thread pools
* with the hosting application.
*
* @deprecated As of release 3.1.1-incubating, not replaced.
* @see <a href="https://issues.apache.org/jira/browse/TINKERPOP-912">TINKERPOP-912</a>
*/
@Deprecated
public GremlinServer(final ServerGremlinExecutor<EventLoopGroup> serverGremlinExecutor) {
this.serverGremlinExecutor = serverGremlinExecutor;
this.settings = serverGremlinExecutor.getSettings();
this.isEpollEnabled = settings.useEpollEventLoop && SystemUtils.IS_OS_LINUX;
if(settings.useEpollEventLoop && !SystemUtils.IS_OS_LINUX){
logger.warn("cannot use epoll in non-linux env, falling back to NIO");
}
Runtime.getRuntime().addShutdownHook(new Thread(() -> this.stop().join(), SERVER_THREAD_PREFIX + "shutdown"));
final ThreadFactory threadFactoryBoss = ThreadFactoryUtil.create("boss-%d");
if(isEpollEnabled) {
bossGroup = new EpollEventLoopGroup(settings.threadPoolBoss, threadFactoryBoss);
} else{
bossGroup = new NioEventLoopGroup(settings.threadPoolBoss, threadFactoryBoss);
}
workerGroup = serverGremlinExecutor.getScheduledExecutorService();
gremlinExecutorService = serverGremlinExecutor.getGremlinExecutorService();
}
示例10: getLocalModFolder
public static String getLocalModFolder() {
if(SystemUtils.IS_OS_LINUX) {
return SystemUtils.getUserHome().toPath().resolve(".local/share/Colossal Order/Cities_Skylines/Addons/Mods").toString();
}
else if(SystemUtils.IS_OS_WINDOWS) {
String dataFolder = System.getenv("LOCALAPPDATA");
return Paths.get(dataFolder).resolve("Colossal Order\\Cities_Skylines\\Addons\\Mods").toString();
}
else if(SystemUtils.IS_OS_MAC_OSX) {
return SystemUtils.getUserHome().toPath().resolve("Library/Application Support/Colossal Order/Cities_Skylines/Addons/Mods").toString();
}
else {
return "";
}
}
示例11: initVideoImportEngine
@Override
public void initVideoImportEngine(Optional<String> pathToLibrary) {
Thread t = new Thread(() -> {
try {
log.debug("Path to library {}", pathToLibrary);
if (SystemUtils.IS_OS_WINDOWS) {
log.debug("Windows OS");
exposeNativeLibrary("libhumblevideo-0.dll");
} else if (SystemUtils.IS_OS_MAC_OSX) {
log.debug("Mac OS");
exposeNativeLibrary("libhumblevideo.dylib");
} else if (SystemUtils.IS_OS_LINUX) {
log.debug("Linux OS");
exposeNativeLibrary("libhumblevideo.so");
} else {
log.error("Unknown OS");
throw new IllegalStateException("Unable to determine OS");
}
/*
Effectively refreshing the library path "stirs the tanks" and preloads the library
before its actual usage by JNI in humble video - note the loadClass doesn't actually
need doing manually but if we don't the initialisation later of the video decoder
is delayed by 5 to 10 seconds and the UI may appear to be frozen.
*/
ClassLoader.getSystemClassLoader().loadClass("io.humble.ferry.FerryJNI").newInstance();
} catch (Throwable t1) {
log.error("Unable to load native library", t1);
}
});
t.setDaemon(true);
// This method is usually quite CPU intensive and can even block the GUI rendering
// despite being in another thread so ensure it is minimum priority
t.setPriority(Thread.MIN_PRIORITY);
t.start();
}
示例12: execute
@Override
public void execute() throws MojoFailureException, MojoExecutionException {
SLF4JBridgeHandler.install();
List<CarnotzetExtension> runtimeExtensions = findRuntimeExtensions();
CarnotzetModuleCoordinates coordinates =
new CarnotzetModuleCoordinates(project.getGroupId(), project.getArtifactId(), project.getVersion());
if (instanceId == null) {
instanceId = Carnotzet.getModuleName(coordinates, Pattern.compile(CarnotzetConfig.DEFAULT_MODULE_FILTER_PATTERN),
Pattern.compile(CarnotzetConfig.DEFAULT_CLASSIFIER_INCLUDE_PATTERN));
}
Path resourcesPath = Paths.get(project.getBuild().getDirectory(), "carnotzet");
if (SystemUtils.IS_OS_WINDOWS) {
// we avoid using ${project.build.directory} because "mvn clean" when the sandbox is running would try to delete mounted files,
// which is not supported on Windows.
resourcesPath = Paths.get("/var/tmp/carnotzet_" + instanceId);
}
CarnotzetConfig config = CarnotzetConfig.builder()
.topLevelModuleId(coordinates)
.resourcesPath(resourcesPath)
.topLevelModuleResourcesPath(project.getBasedir().toPath().resolve("src/main/resources"))
.failOnDependencyCycle(failOnDependencyCycle)
.extensions(runtimeExtensions)
.build();
carnotzet = new Carnotzet(config);
if (bindLocalPorts == null) {
bindLocalPorts = !SystemUtils.IS_OS_LINUX;
}
runtime = new DockerComposeRuntime(carnotzet, instanceId, DefaultCommandRunner.INSTANCE, bindLocalPorts);
executeInternal();
SLF4JBridgeHandler.uninstall();
}
示例13: ensureNetworkCommunicationIsPossible
private void ensureNetworkCommunicationIsPossible() {
if (!SystemUtils.IS_OS_LINUX) {
return;
}
String buildContainerId =
runCommandAndCaptureOutput("/bin/bash", "-c", "docker ps | grep $(hostname) | grep -v k8s_POD | cut -d ' ' -f 1");
if (Strings.isNullOrEmpty(buildContainerId)) {
// we are probably not running inside a container, networking should be fine
return;
}
log.debug("Execution from inside a container detected! Attempting to configure container networking to allow communication.");
String networkMode =
runCommandAndCaptureOutput("/bin/bash", "-c", "docker inspect -f '{{.HostConfig.NetworkMode}}' " + buildContainerId);
String containerToConnect = buildContainerId;
// shared network stack
if (networkMode.startsWith("container:")) {
containerToConnect = networkMode.replace("container:", "");
log.debug("Detected a shared container network stack.");
}
log.debug("attaching container [" + containerToConnect + "] to network [" + getDockerNetworkName() + "]");
runCommand("/bin/bash", "-c", "docker network connect " + getDockerNetworkName() + " " + containerToConnect);
}
示例14: sanitizeName
public static String sanitizeName( String name ) {
if( null == name ) {
return "";
}
if( SystemUtils.IS_OS_LINUX ) {
return name.replaceAll( "/+", "" ).trim();
}
return name.replaceAll( "[\u0001-\u001f<>:\"/\\\\|?*\u007f]+", "" ).trim();
}
示例15: getPrefLocation
/**
* As per Chromium
* https://www.chromium.org/user-experience/user-data-directory
* @return Preferences location
*/
public static String getPrefLocation() {
if (SystemUtils.IS_OS_WINDOWS) {
return SystemUtils.getUserHome().getAbsolutePath() + "/AppData/Local/Google/Chrome/User Data/Default";
}
if (SystemUtils.IS_OS_MAC_OSX) {
return SystemUtils.getUserHome().getAbsolutePath()+"/Library/Application Support/Google/Chrome/Default";
}
if (SystemUtils.IS_OS_LINUX) {
return SystemUtils.getUserHome().getAbsolutePath()+"/.config/google-chrome/Default";
}
return "OSNotConfigured";
}