Java Code Examples for com.intellij.openapi.vfs.CharsetToolkit#getDefaultSystemCharset()
The following examples show how to use
com.intellij.openapi.vfs.CharsetToolkit#getDefaultSystemCharset() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NoSqlConfigurable.java From nosql4idea with Apache License 2.0 | 5 votes |
public ProcessOutput checkShellPath(DatabaseVendor databaseVendor, String shellPath) throws ExecutionException, TimeoutException { if (isBlank(shellPath)) { return null; } GeneralCommandLine commandLine = new GeneralCommandLine(); commandLine.setExePath(shellPath); if (testParameter != null) { commandLine.addParameter(testParameter); } CapturingProcessHandler handler = new CapturingProcessHandler(commandLine.createProcess(), CharsetToolkit.getDefaultSystemCharset()); ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); ProcessOutput result = indicator == null ? handler.runProcess(TIMEOUT_MS) : handler.runProcessWithProgressIndicator(indicator); if (result.isTimeout()) { throw new TimeoutException("Couldn't check " + databaseVendor.name + " CLI executable - stopped by timeout."); } else if (result.isCancelled()) { throw new ProcessCanceledException(); } else if (result.getExitCode() != 0 || !result.getStderr().isEmpty()) { throw new ExecutionException(String.format("Errors while executing %s. exitCode=%s errors: %s", commandLine.toString(), result.getExitCode(), result.getStderr())); } return result; }
Example 2
Source File: EnvironmentUtil.java From consulo with Apache License 2.0 | 5 votes |
private static Map<String, String> setCharsetVar(@Nonnull Map<String, String> env) { if (!isCharsetVarDefined(env)) { Locale locale = Locale.getDefault(); Charset charset = CharsetToolkit.getDefaultSystemCharset(); String language = locale.getLanguage(); String country = locale.getCountry(); String value = (language.isEmpty() || country.isEmpty() ? "en_US" : language + '_' + country) + '.' + charset.name(); env.put(LC_CTYPE, value); LOG.info("LC_CTYPE=" + value); } return env; }
Example 3
Source File: Executor.java From consulo with Apache License 2.0 | 5 votes |
protected static String run(List<String> params) { final ProcessBuilder builder = new ProcessBuilder().command(params); builder.directory(ourCurrentDir()); builder.redirectErrorStream(true); Process clientProcess; try { clientProcess = builder.start(); } catch (IOException e) { throw new RuntimeException(e); } CapturingProcessHandler handler = new CapturingProcessHandler(clientProcess, CharsetToolkit.getDefaultSystemCharset(), StringUtil.join(params, " ")); ProcessOutput result = handler.runProcess(30*1000); if (result.isTimeout()) { throw new RuntimeException("Timeout waiting for the command execution. Command: " + StringUtil.join(params, " ")); } if (result.getExitCode() != 0) { log("{" + result.getExitCode() + "}"); } String stdout = result.getStdout().trim(); if (!StringUtil.isEmptyOrSpaces(stdout)) { log(stdout.trim()); } return stdout; }
Example 4
Source File: LightEncodingProjectManager.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public Charset getDefaultCharset() { return CharsetToolkit.getDefaultSystemCharset(); }
Example 5
Source File: TestClientRunner.java From consulo with Apache License 2.0 | 4 votes |
public ProcessOutput runClient(@Nonnull String exeName, @javax.annotation.Nullable String stdin, @javax.annotation.Nullable final File workingDir, String... commandLine) throws IOException { final List<String> arguments = new ArrayList<String>(); final File client = new File(myClientBinaryPath, SystemInfo.isWindows ? exeName + ".exe" : exeName); if (client.exists()) { arguments.add(client.toString()); } else { // assume client is in path arguments.add(exeName); } Collections.addAll(arguments, commandLine); if (myTraceClient) { LOG.info("*** running:\n" + arguments); if (StringUtil.isNotEmpty(stdin)) { LOG.info("*** stdin:\n" + stdin); } } final ProcessBuilder builder = new ProcessBuilder().command(arguments); if (workingDir != null) { builder.directory(workingDir); } if (myClientEnvironment != null) { builder.environment().putAll(myClientEnvironment); } final Process clientProcess = builder.start(); if (stdin != null) { final OutputStream outputStream = clientProcess.getOutputStream(); try { final byte[] bytes = stdin.getBytes(); outputStream.write(bytes); } finally { outputStream.close(); } } final CapturingProcessHandler handler = new CapturingProcessHandler(clientProcess, CharsetToolkit.getDefaultSystemCharset(), StringUtil.join(arguments, " ")); final ProcessOutput result = handler.runProcess(100 * 1000, false); if (myTraceClient || result.isTimeout()) { LOG.debug("*** result: " + result.getExitCode()); final String out = result.getStdout().trim(); if (out.length() > 0) { LOG.debug("*** output:\n" + out); } final String err = result.getStderr().trim(); if (err.length() > 0) { LOG.debug("*** error:\n" + err); } } if (result.isTimeout()) { String processList = LogUtil.getProcessList(); handler.destroyProcess(); throw new RuntimeException("Timeout waiting for VCS client to finish execution:\n" + processList); } return result; }
Example 6
Source File: EnvironmentUtil.java From consulo with Apache License 2.0 | 4 votes |
public StreamGobbler(@Nonnull InputStream stream) { super(stream, CharsetToolkit.getDefaultSystemCharset(), OPTIONS); myBuffer = new StringBuffer(); start("stdout/stderr streams of shell env loading process"); }
Example 7
Source File: EncodingManagerImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override @Nonnull public Charset getDefaultCharset() { return myState.myDefaultEncoding == ChooseFileEncodingAction.NO_ENCODING ? CharsetToolkit.getDefaultSystemCharset() : myState.myDefaultEncoding; }
Example 8
Source File: CoreEncodingProjectManager.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public Charset getDefaultCharset() { return CharsetToolkit.getDefaultSystemCharset(); }