Java Code Examples for java.nio.charset.Charset#toString()

The following examples show how to use java.nio.charset.Charset#toString() . These examples are extracted from open source projects. 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
private void loadCompilerOptions() {
    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
    mCompileOptions = new CompileOptions();

    String sourceCompatibility = pref.getString(context.getString(R.string.key_pref_source_compatibility), null);
    if (sourceCompatibility == null || sourceCompatibility.isEmpty()) {
        sourceCompatibility = JavaVersion.VERSION_1_7.toString();
    }
    mCompileOptions.setSourceCompatibility(sourceCompatibility);


    String targetCompatibility = pref.getString(context.getString(R.string.key_pref_target_compatibility), null);
    if (targetCompatibility == null || targetCompatibility.isEmpty()) {
        targetCompatibility = JavaVersion.VERSION_1_7.toString();
    }
    mCompileOptions.setTargetCompatibility(targetCompatibility);

    String encoding = pref.getString(context.getString(R.string.key_pref_source_encoding), null);
    if (encoding == null || encoding.isEmpty()) {
        encoding = Charset.forName("UTF-8").toString();
    } else {
        try {
            Charset charset = Charset.forName(encoding);
            encoding = charset.toString();
        } catch (Exception e) {
            encoding = Charset.forName("UTF-8").toString();
        }
    }
    mCompileOptions.setEncoding(encoding);
}
 
Example 2
Source Project: Aurora   File: RequestInterceptor.java    License: Apache License 2.0 5 votes vote down vote up
public static String convertCharset(Charset charset) {
    String s = charset.toString();
    int i = s.indexOf("[");
    if (i == -1)
        return s;
    return s.substring(i + 1, s.length() - 1);
}
 
Example 3
Source Project: MVVMArms   File: RequestInterceptor.java    License: Apache License 2.0 5 votes vote down vote up
public static String convertCharset(Charset charset) {
    String s = charset.toString();
    int i = s.indexOf("[");
    if (i == -1) {
        return s;
    }
    return s.substring(i + 1, s.length() - 1);
}
 
Example 4
Source Project: MVPArms   File: RequestInterceptor.java    License: Apache License 2.0 5 votes vote down vote up
public static String convertCharset(Charset charset) {
    String s = charset.toString();
    int i = s.indexOf("[");
    if (i == -1) {
        return s;
    }
    return s.substring(i + 1, s.length() - 1);
}
 
Example 5
Source Project: zstack   File: PathUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static String readFileToString(String path, Charset charset) {
    try (UnicodeReader reader = new UnicodeReader(new FileInputStream(new File(path)), charset.toString())) {
        return IOUtils.toString(reader);
    } catch (IOException e) {
        throw new RuntimeException(e.getMessage());
    }
}
 
Example 6
private String getResponseBodyAsString(ClientHttpResponse response) {
    try {
        Charset charset = getCharset(response);
        return new String(getResponseBody(response), charset != null ? charset.toString() : DEFAULT_CHARSET);
    } catch (UnsupportedEncodingException ex) {
        throw new InternalException(RestClientResponseErrorHandler.class, "E-SPRINGMVC-REST-CLIENT-HANDLER#0001");
    }
}
 
Example 7
public FromFileProperty(File file, Class type, Charset charset) {
	this.file = file;
	this.type = type;
	this.charset = charset.toString();
}