Example usage for org.apache.commons.lang CharEncoding UTF_8

List of usage examples for org.apache.commons.lang CharEncoding UTF_8

Introduction

In this page you can find the example usage for org.apache.commons.lang CharEncoding UTF_8.

Prototype

String UTF_8

To view the source code for org.apache.commons.lang CharEncoding UTF_8.

Click Source Link

Document

Eight-bit Unicode Transformation Format.

Usage

From source file:org.sonar.api.rules.StandardRulesXmlParser.java

public List<Rule> parse(InputStream input) {
    try {//www .j a v a2  s .c om
        return setDefaultRuleSeverities(
                (List<Rule>) getXStream().fromXML(new InputStreamReader(input, CharEncoding.UTF_8)));

    } catch (UnsupportedEncodingException e) {
        throw new SonarException("Can't parse xml file", e);
    }
}

From source file:org.sonar.api.rules.XMLRuleParser.java

public List<Rule> parse(File file) {
    Reader reader = null;//from w ww . jav  a2  s.c o m
    try {
        reader = new InputStreamReader(FileUtils.openInputStream(file), CharEncoding.UTF_8);
        return parse(reader);

    } catch (IOException e) {
        throw new SonarException("Fail to load the file: " + file, e);

    } finally {
        Closeables.closeQuietly(reader);
    }
}

From source file:org.sonar.api.rules.XMLRuleParser.java

/**
 * Warning : the input stream is closed in this method
 *//* ww w .j a  v a 2 s .c  o  m*/
public List<Rule> parse(InputStream input) {
    Reader reader = null;
    try {
        reader = new InputStreamReader(input, CharEncoding.UTF_8);
        return parse(reader);

    } catch (IOException e) {
        throw new SonarException("Fail to load the xml stream", e);

    } finally {
        Closeables.closeQuietly(reader);
    }
}

From source file:org.sonar.api.scan.filesystem.SimpleModuleFileSystem.java

public Charset sourceCharset() {
    return Charset.forName(CharEncoding.UTF_8);
}

From source file:org.sonar.api.test.SimpleProjectFileSystem.java

public File writeToWorkingDirectory(String content, String filename) throws IOException {
    File file = new File(getSonarWorkingDirectory(), filename);
    FileUtils.writeStringToFile(file, content, CharEncoding.UTF_8);
    return file;//  w  w w.  j  a va2s .  com
}

From source file:org.sonar.batch.scan.filesystem.DeprecatedFileSystemAdapter.java

public File writeToWorkingDirectory(String content, String fileName) throws IOException {
    File file = new File(target.workingDir(), fileName);
    FileUtils.writeStringToFile(file, content, CharEncoding.UTF_8);
    return file;/* www. j ava2  s .c  o  m*/
}

From source file:org.sonar.batch.scan.filesystem.ProjectFileSystemAdapter.java

@Override
public File writeToWorkingDirectory(String content, String fileName) throws IOException {
    File file = new File(target.workingDir(), fileName);
    FileUtils.writeStringToFile(file, content, CharEncoding.UTF_8);
    return file;/*from  www. j ava  2s. c o  m*/
}

From source file:org.sonar.java.ast.JavaAstScannerTest.java

@Test
public void testUTF8Encoding() {
    squid = new Squid(new JavaSquidConfiguration(false, Charset.forName(CharEncoding.UTF_8)));
    squid.register(JavaAstScanner.class).scanFile(getFile("/special_cases/encoding/Utf8Encoding.java"));
    SourceProject prj = squid.aggregate();
    assertEquals(4, prj.getInt(Metric.METHODS));
}

From source file:org.sonar.plugins.android.lint.AndroidLintRuleParser.java

public List<Rule> parse(File file) {
    BufferedReader reader = null;
    try {//from  w  w  w. jav a 2  s.  co m
        reader = new BufferedReader(new InputStreamReader(FileUtils.openInputStream(file), CharEncoding.UTF_8));
        return parse(reader);

    } catch (IOException e) {
        throw new SonarException("Fail to load the file: " + file, e);

    } finally {
        Closeables.closeQuietly(reader);
    }
}

From source file:org.sonar.plugins.android.lint.AndroidLintRuleParser.java

/**
 * Warning : the input stream is closed in this method
 *//*from   www . ja v  a2s  .c o  m*/
public List<Rule> parse(InputStream input) {
    BufferedReader reader = null;
    try {
        reader = new BufferedReader(new InputStreamReader(input, CharEncoding.UTF_8));
        return parse(reader);

    } catch (IOException e) {
        throw new SonarException("Fail to load the xml stream", e);

    } finally {
        Closeables.closeQuietly(reader);
    }
}