當前位置: 首頁>>代碼示例>>Java>>正文


Java SystemUtils類代碼示例

本文整理匯總了Java中org.apache.commons.lang3.SystemUtils的典型用法代碼示例。如果您正苦於以下問題:Java SystemUtils類的具體用法?Java SystemUtils怎麽用?Java SystemUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SystemUtils類屬於org.apache.commons.lang3包,在下文中一共展示了SystemUtils類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setNodeHeight

import org.apache.commons.lang3.SystemUtils; //導入依賴的package包/類
/**
 * Sets the node height used for drawing.
 * <p>
 * Also updates the font size used for drawing sequences within nodes.
 *
 * @param nodeHeight the node height
 */
public final void setNodeHeight(final double nodeHeight) {
    this.nodeHeight = nodeHeight;
    this.snpHeight = nodeHeight * SNP_HEIGHT_FACTOR;

    final Text text = new Text("X");
    text.setFont(new Font(DEFAULT_NODE_FONT, 1));

    final double font1PHeight = text.getLayoutBounds().getHeight();

    final String font;

    if (SystemUtils.IS_OS_MAC) {
        font = DEFAULT_MAC_NODE_FONT;
    } else {
        font = DEFAULT_NODE_FONT;
    }

    final double fontSize = DEFAULT_NODE_FONT_HEIGHT_SCALAR * nodeHeight / font1PHeight;
    this.nodeFont = new Font(font, fontSize);
    text.setFont(nodeFont);

    this.charWidth = text.getLayoutBounds().getWidth();
    this.charHeight = text.getLayoutBounds().getHeight();
}
 
開發者ID:ProgrammingLife2017,項目名稱:hygene,代碼行數:32,代碼來源:NodeDrawingToolkit.java

示例2: doStart

import org.apache.commons.lang3.SystemUtils; //導入依賴的package包/類
private void doStart() {
	try {
		String[] command;
		if (SystemUtils.IS_OS_WINDOWS) {
			// for windows test
			command = new String[] { "C:/Program Files/Java/jdk1.8.0_91/bin/java", "-version" };
		} else {
			// real use
			Assert.notNull(file);
			command = new String[] { this.command, argf, calculateFileName() };
		}
		process = new ProcessBuilder(command).redirectErrorStream(true).start();
		BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
		String line = null;
		while ((line = input.readLine()) != null) {
			content.add(String.format("%s : %s", name, line));
			this.checkForEviction();
		}
		int exitVal = process.waitFor();
		log.info("Exited with error code " + exitVal);
	} catch (Exception e) {
		log.error("Error", e);
		throw new RuntimeException(e);
	}
}
 
開發者ID:XinYang-Pan,項目名稱:LogMonitor,代碼行數:26,代碼來源:LogMonitorSimple.java

示例3: getLogger

import org.apache.commons.lang3.SystemUtils; //導入依賴的package包/類
/**
 * Creates a static {@code Logger} instance.
 * 
 * @return a static {@code Logger} with properties:
 *         <ul>
 *         <li>Name: {@code "DefaultDatabaseConfigurator"}.</li>
 *         <li>Output file pattern:
 *         {@code user.home/.kawansoft/log/AceQL.log}.</li>
 *         <li>Formatter: {@code SimpleFormatter}.</li>
 *         <li>Limit: 200Mb.</li>
 *         <li>Count (number of files to use): 2.</li>
 *         </ul>
 */
@Override
public Logger getLogger() throws IOException {
	if (ACEQL_LOGGER != null) {
		return ACEQL_LOGGER;
	}

	File logDir = new File(SystemUtils.USER_HOME + File.separator + ".kawansoft" + File.separator + "log");
	logDir.mkdirs();

	String pattern = logDir.toString() + File.separator + "AceQL.log";

	ACEQL_LOGGER = Logger.getLogger(DefaultDatabaseConfigurator.class.getName());
	Handler fh = new FileHandler(pattern, 200 * 1024 * 1024, 2, true);
	fh.setFormatter(new SimpleFormatter());
	ACEQL_LOGGER.addHandler(fh);
	return ACEQL_LOGGER;

}
 
開發者ID:kawansoft,項目名稱:aceql-http,代碼行數:32,代碼來源:DefaultDatabaseConfigurator.java

示例4: getProductFile

import org.apache.commons.lang3.SystemUtils; //導入依賴的package包/類
/**
    * 
    * @return the product file that contains the product name
    */
   private static File getProductFile() {
// Use absolute directory: client side and Tomcat side don'ts have same
// user.home value!
String exchangeDir = null;

if (SystemUtils.IS_OS_WINDOWS) {
    exchangeDir = "c:\\temp\\";
} else {
    if (FrameworkSystemUtil.isAndroid()) {
	// exchangeDir = "/sdcard/";
	exchangeDir = System.getProperty("java.io.tmpdir");
	if (!exchangeDir.endsWith(System.getProperty("file.separator"))) {
	    exchangeDir += System.getProperty("file.separator");
	}
    } else {
	exchangeDir = "/tmp/";
    }

}

File productFile = new File(exchangeDir + "aceql-database-to-use.txt");
return productFile;
   }
 
開發者ID:kawansoft,項目名稱:aceql-http,代碼行數:28,代碼來源:UserPrefManager.java

示例5: read

import org.apache.commons.lang3.SystemUtils; //導入依賴的package包/類
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);
    }
}
 
開發者ID:sip3io,項目名稱:tapir,代碼行數:25,代碼來源:GzipFileReader.java

示例6: deleteRecursively

import org.apache.commons.lang3.SystemUtils; //導入依賴的package包/類
/**
 * Delete a file or directory and its contents recursively.
 * Don't follow directories if they are symlinks.
 *
 * @param file Input file / dir to be deleted
 * @throws IOException if deletion is unsuccessful
 */
public static void deleteRecursively(File file) throws IOException {
  if (file == null) { return; }

  // On Unix systems, use operating system command to run faster
  // If that does not work out, fallback to the Java IO way
  if (SystemUtils.IS_OS_UNIX) {
    try {
      deleteRecursivelyUsingUnixNative(file);
      return;
    } catch (IOException e) {
      logger.warn("Attempt to delete using native Unix OS command failed for path = {}. " +
                      "Falling back to Java IO way", file.getAbsolutePath(), e);
    }
  }

  deleteRecursivelyUsingJavaIO(file);
}
 
開發者ID:spafka,項目名稱:spark_deep,代碼行數:25,代碼來源:JavaUtils.java

示例7: getModules

import org.apache.commons.lang3.SystemUtils; //導入依賴的package包/類
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;
}
 
開發者ID:swissquote,項目名稱:carnotzet,代碼行數:23,代碼來源:Carnotzet.java

示例8: getSensor

import org.apache.commons.lang3.SystemUtils; //導入依賴的package包/類
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);
			}
		};
	}
}
 
開發者ID:Tankernn,項目名稱:JavaGridControl,代碼行數:18,代碼來源:SensorFactory.java

示例9: solve

import org.apache.commons.lang3.SystemUtils; //導入依賴的package包/類
@Override
public Solution solve(final Board board, final Configuration configuration) throws SolutionException {
    LOG.traceEntry("solve(board={}, configuration={})", board, configuration);

    LOG.debug("Attempting serial solve for board:{}{}", SystemUtils.LINE_SEPARATOR, board);

    for (final Move move : board.getAvailableMoves()) {
        try {
            final Solution solution = new SolutionSearch(configuration, move).search();

            LOG.debug("Found solution:{}{}", SystemUtils.LINE_SEPARATOR, solution);

            return LOG.traceExit(solution);
        } catch (SolutionException e) {
            // Ignore failed solution
        }
    }

    LOG.debug("No solution found");

    return LOG.traceExit(new Solution(configuration));
}
 
開發者ID:neocotic,項目名稱:brick-pop-solver,代碼行數:23,代碼來源:SerialSolutionService.java

示例10: solve

import org.apache.commons.lang3.SystemUtils; //導入依賴的package包/類
public Solution solve(final Board board) throws BrickPopSolverException {
    LOG.traceEntry("solve(board={})", board);

    Objects.requireNonNull(board, "board");

    LOG.info("Solving board: {}", board);

    final SolutionService solutionService = configuration.getSolutionService();
    final Instant start = Instant.now();
    final Solution solution = solutionService.solve(board, configuration);
    final Instant end = Instant.now();

    if (solution.isEmpty()) {
        throw new SolutionException("No solution could be found");
    }

    LOG.info("Found a solution in {} seconds:{}{}", () -> Duration.between(start, end).getSeconds(), () -> SystemUtils.LINE_SEPARATOR, () -> solution);

    return LOG.traceExit(solution);
}
 
開發者ID:neocotic,項目名稱:brick-pop-solver,代碼行數:21,代碼來源:BrickPopSolver.java

示例11: init

import org.apache.commons.lang3.SystemUtils; //導入依賴的package包/類
@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");
}
 
開發者ID:edylle,項目名稱:pathological-reports,代碼行數:20,代碼來源:ImagePathProperties.java

示例12: setOnScrollListener

import org.apache.commons.lang3.SystemUtils; //導入依賴的package包/類
/**
 * Enables handling of scroll and mouse wheel events for the node.
 * This type of events has a peculiarity on Windows. See the javadoc of notifyScrollEvents for more information.
 * @see #notifyScrollEvent
 * @param intersectionTestFunc a function that takes an event object and must return boolean
 * @return itself to let you use a chain of calls
 */
MouseEventNotificator setOnScrollListener(Function<NativeMouseWheelEvent, Boolean> intersectionTestFunc) {
    if (SystemUtils.IS_OS_WINDOWS) {
        if (!GlobalScreen.isNativeHookRegistered()) {
            try {
                GlobalScreen.registerNativeHook();
            } catch (NativeHookException | UnsatisfiedLinkError e) {
                e.printStackTrace();
                Main.log("Failed to initialize the native hooking. Rolling back to using JavaFX events...");
                sender.addEventFilter(ScrollEvent.SCROLL, this::notifyScrollEvent);
                return this;
            }
        }
        mouseWheelListener = event -> notifyScrollEvent(event, intersectionTestFunc);
        GlobalScreen.addNativeMouseWheelListener(mouseWheelListener);
    } else {
        sender.addEventFilter(ScrollEvent.SCROLL, this::notifyScrollEvent);
    }

    return this;
}
 
開發者ID:DeskChan,項目名稱:DeskChan,代碼行數:28,代碼來源:MouseEventNotificator.java

示例13: getSteamDir

import org.apache.commons.lang3.SystemUtils; //導入依賴的package包/類
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;
}
 
開發者ID:Idrinths-Stellaris-Mods,項目名稱:Mod-Tools,代碼行數:18,代碼來源:DirectoryLookup.java

示例14: diaplayWarnForDetach

import org.apache.commons.lang3.SystemUtils; //導入依賴的package包/類
private void diaplayWarnForDetach(JFrame parent) {
    if (Config.instance().to().getBoolean(Config.Entry.WARN_ON_OSX_TO_DETACH.key(), SystemUtils.IS_OS_MAC_OSX)) {
        if (planTowerSensor.isConnected()) {
            JOptionPane.showMessageDialog(parent,
                    "<html>The sensor is still attached.<br><br>" +
                    "This instance or the next start of the application may <b>hang</b><br>" +
                    "when the device is still attached while app or port is being closed.<br>" +
                    "<b>In such a case only reboot helps.</b><br><br>" +
                    "This behavior is being observed when using some cheap PL2303<br>" +
                    "uart-to-usb and their drivers.<br><br>" +
                    "You can now forcibly detach the device now.<br><br>" +
                    "Press OK to continue closing.</html>",
                    "Warning", JOptionPane.WARNING_MESSAGE);
        }
    }
    
}
 
開發者ID:rjaros87,項目名稱:pm-home-station,代碼行數:18,代碼來源:Station.java

示例15: setLookAndFeel

import org.apache.commons.lang3.SystemUtils; //導入依賴的package包/類
private static void setLookAndFeel() {
    if (SystemUtils.IS_OS_MAC_OSX) {
        // must be before any AWT interaction
        System.setProperty("apple.laf.useScreenMenuBar", "true"); // place menubar (if any) in native menu bar
        System.setProperty("apple.awt.application.name", Constants.PROJECT_NAME);
        if (Config.instance().to().getBoolean(Config.Entry.SYSTEM_TRAY.key(), Constants.SYSTEM_TRAY)) {
            logger.debug("Hiding dock icon since system-tray integration is enabled");
            System.setProperty("apple.awt.UIElement", "true");
        }
    }
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
            | UnsupportedLookAndFeelException e) {
        logger.error("Ooops, problem setting system L&F", e);
    }
}
 
開發者ID:rjaros87,項目名稱:pm-home-station,代碼行數:18,代碼來源:Start.java


注:本文中的org.apache.commons.lang3.SystemUtils類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。