本文整理汇总了Java中com.intellij.openapi.vfs.CharsetToolkit.getDefaultSystemCharset方法的典型用法代码示例。如果您正苦于以下问题:Java CharsetToolkit.getDefaultSystemCharset方法的具体用法?Java CharsetToolkit.getDefaultSystemCharset怎么用?Java CharsetToolkit.getDefaultSystemCharset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.vfs.CharsetToolkit
的用法示例。
在下文中一共展示了CharsetToolkit.getDefaultSystemCharset方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doCheckExecutable
import com.intellij.openapi.vfs.CharsetToolkit; //导入方法依赖的package包/类
protected static boolean doCheckExecutable(@NotNull String executable, @NotNull List<String> processParameters) {
try {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath(executable);
commandLine.addParameters(processParameters);
CapturingProcessHandler handler = new CapturingProcessHandler(commandLine.createProcess(), CharsetToolkit.getDefaultSystemCharset());
ProcessOutput result = handler.runProcess(TIMEOUT_MS);
boolean timeout = result.isTimeout();
int exitCode = result.getExitCode();
String stderr = result.getStderr();
if (timeout) {
LOG.warn("Validation of " + executable + " failed with a timeout");
}
if (exitCode != 0) {
LOG.warn("Validation of " + executable + " failed with a non-zero exit code: " + exitCode);
}
if (!stderr.isEmpty()) {
LOG.warn("Validation of " + executable + " failed with a non-empty error output: " + stderr);
}
return !timeout && exitCode == 0 && stderr.isEmpty();
}
catch (Throwable t) {
LOG.warn(t);
return false;
}
}
示例2: setCharsetVar
import com.intellij.openapi.vfs.CharsetToolkit; //导入方法依赖的package包/类
private static Map<String, String> setCharsetVar(@NotNull 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;
}
示例3: getEncoding
import com.intellij.openapi.vfs.CharsetToolkit; //导入方法依赖的package包/类
@Nullable
public Charset getEncoding() {
final Object selectedItem = myEncoding.getSelectedItem();
if (SYSTEM_DEFAULT.equals(selectedItem)) {
return CharsetToolkit.getDefaultSystemCharset();
}
return (Charset)selectedItem;
}
示例4: run
import com.intellij.openapi.vfs.CharsetToolkit; //导入方法依赖的package包/类
@NotNull
protected static String run(@NotNull File workingDir, @NotNull List<String> params, boolean ignoreNonZeroExitCode)
throws ExecutionException
{
final ProcessBuilder builder = new ProcessBuilder().command(params);
builder.directory(workingDir);
builder.redirectErrorStream(true);
Process clientProcess;
try {
clientProcess = builder.start();
}
catch (IOException e) {
throw new RuntimeException(e);
}
CapturingProcessHandler handler = new CapturingProcessHandler(clientProcess, CharsetToolkit.getDefaultSystemCharset());
ProcessOutput result = handler.runProcess(30 * 1000);
if (result.isTimeout()) {
throw new RuntimeException("Timeout waiting for the command execution. Command: " + StringUtil.join(params, " "));
}
String stdout = result.getStdout().trim();
if (result.getExitCode() != 0) {
if (ignoreNonZeroExitCode) {
debug("{" + result.getExitCode() + "}");
}
debug(stdout);
if (!ignoreNonZeroExitCode) {
throw new ExecutionException(result.getExitCode(), stdout);
}
}
else {
debug(stdout);
}
return stdout;
}
示例5: identifyVersion
import com.intellij.openapi.vfs.CharsetToolkit; //导入方法依赖的package包/类
@NotNull
public static GitVersion identifyVersion(String gitExecutable) throws TimeoutException, ExecutionException, ParseException {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath(gitExecutable);
commandLine.addParameter("--version");
CapturingProcessHandler handler = new CapturingProcessHandler(commandLine.createProcess(), CharsetToolkit.getDefaultSystemCharset());
ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
ProcessOutput result = indicator == null ?
handler.runProcess(ExecutableValidator.TIMEOUT_MS) :
handler.runProcessWithProgressIndicator(indicator);
if (result.isTimeout()) {
throw new TimeoutException("Couldn't identify the version of Git - stopped by timeout.");
}
else if (result.isCancelled()) {
LOG.info("Cancelled by user. exitCode=" + result.getExitCode());
throw new ProcessCanceledException();
}
else if (result.getExitCode() != 0 || !result.getStderr().isEmpty()) {
LOG.info("getVersion exitCode=" + result.getExitCode() + " errors: " + result.getStderr());
// anyway trying to parse
try {
parse(result.getStdout());
} catch (ParseException pe) {
throw new ExecutionException("Errors while executing git --version. exitCode=" + result.getExitCode() +
" errors: " + result.getStderr());
}
}
return parse(result.getStdout());
}
示例6: runs
import com.intellij.openapi.vfs.CharsetToolkit; //导入方法依赖的package包/类
/**
* Checks if it is possible to run the specified program.
* Made protected for tests not to start a process there.
*/
protected boolean runs(@NotNull String exec) {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath(exec);
try {
CapturingProcessHandler handler = new CapturingProcessHandler(commandLine.createProcess(), CharsetToolkit.getDefaultSystemCharset());
ProcessOutput result = handler.runProcess((int)TimeUnit.SECONDS.toMillis(5));
return !result.isTimeout();
}
catch (ExecutionException e) {
return false;
}
}
示例7: getVersionOutput
import com.intellij.openapi.vfs.CharsetToolkit; //导入方法依赖的package包/类
@NotNull
public static HgCommandResult getVersionOutput(@NotNull String executable) throws ShellCommandException, InterruptedException {
String hgExecutable = executable.trim();
List<String> cmdArgs = new ArrayList<String>();
cmdArgs.add(hgExecutable);
cmdArgs.add("version");
cmdArgs.add("-q");
ShellCommand shellCommand = new ShellCommand(cmdArgs, null, CharsetToolkit.getDefaultSystemCharset());
return shellCommand.execute(false, false);
}
示例8: getCharset
import com.intellij.openapi.vfs.CharsetToolkit; //导入方法依赖的package包/类
@Override
public String getCharset(@NotNull VirtualFile file, @NotNull final byte[] content) {
Charset charset = EncodingRegistry.getInstance().getDefaultCharsetForPropertiesFiles(file);
if (charset == null) {
charset = CharsetToolkit.getDefaultSystemCharset();
}
return charset.name();
}
示例9: getDefaultCharset
import com.intellij.openapi.vfs.CharsetToolkit; //导入方法依赖的package包/类
@Override
@NotNull
public Charset getDefaultCharset() {
return myState.myDefaultEncoding == ChooseFileEncodingAction.NO_ENCODING ? CharsetToolkit.getDefaultSystemCharset() : myState.myDefaultEncoding;
}
示例10: getDefaultCharset
import com.intellij.openapi.vfs.CharsetToolkit; //导入方法依赖的package包/类
@NotNull
@Override
public Charset getDefaultCharset() {
return CharsetToolkit.getDefaultSystemCharset();
}
示例11: runClient
import com.intellij.openapi.vfs.CharsetToolkit; //导入方法依赖的package包/类
public ProcessOutput runClient(@NotNull String exeName,
@Nullable String stdin,
@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());
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;
}