本文整理汇总了Java中com.intellij.openapi.vfs.CharsetToolkit.UTF8属性的典型用法代码示例。如果您正苦于以下问题:Java CharsetToolkit.UTF8属性的具体用法?Java CharsetToolkit.UTF8怎么用?Java CharsetToolkit.UTF8使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.intellij.openapi.vfs.CharsetToolkit
的用法示例。
在下文中一共展示了CharsetToolkit.UTF8属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadClassNames
private static List<String> loadClassNames(URL url) throws IOException {
List<String> result = new ArrayList<String>();
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(), CharsetToolkit.UTF8));
try {
String line;
while ((line = in.readLine()) != null) {
int i = line.indexOf('#');
if (i >= 0) line = line.substring(0, i);
line = line.trim();
if (!line.isEmpty()) {
result.add(line);
}
}
}
finally {
in.close();
}
return result;
}
示例2: writeClassesPerModule
protected void writeClassesPerModule(String packageName, JavaParameters javaParameters, Map<Module, List<String>> perModule)
throws FileNotFoundException, UnsupportedEncodingException, CantRunException {
if (perModule != null && perModule.size() > 1) {
final String classpath = getScope() == TestSearchScope.WHOLE_PROJECT
? null : javaParameters.getClassPath().getPathsString();
final PrintWriter wWriter = new PrintWriter(myWorkingDirsFile, CharsetToolkit.UTF8);
try {
wWriter.println(packageName);
for (Module module : perModule.keySet()) {
wWriter.println(PathMacroUtil.getModuleDir(module.getModuleFilePath()));
wWriter.println(module.getName());
if (classpath == null) {
final JavaParameters parameters = new JavaParameters();
parameters.getClassPath().add(JavaSdkUtil.getIdeaRtJarPath());
configureRTClasspath(parameters);
JavaParametersUtil.configureModule(module, parameters, JavaParameters.JDK_AND_CLASSES_AND_TESTS,
getConfiguration().isAlternativeJrePathEnabled() ? getConfiguration()
.getAlternativeJrePath() : null);
wWriter.println(parameters.getClassPath().getPathsString());
}
else {
wWriter.println(classpath);
}
final List<String> classNames = perModule.get(module);
wWriter.println(classNames.size());
for (String className : classNames) {
wWriter.println(className);
}
}
}
finally {
wWriter.close();
}
}
}
示例3: getCharset
@Override
public String getCharset(@NotNull VirtualFile file, @NotNull byte[] content) {
if (CharsetToolkit.hasUTF8Bom(content)) {
return CharsetToolkit.UTF8;
}
ByteBuffer bytes = ByteBuffer.wrap(content, 0, Math.min(256, content.length));
String decoded = CharsetToolkit.UTF8_CHARSET.decode(bytes).toString();
return getCharsetFromEncodingDeclaration(StringUtil.convertLineSeparators(decoded));
}
示例4: createJsonEntity
protected static RequestEntity createJsonEntity(String requestBody) {
try {
return new StringRequestEntity(requestBody, "application/json", CharsetToolkit.UTF8);
}
catch (UnsupportedEncodingException e) {
throw new AssertionError("UTF-8 encoding is not supported");
}
}
示例5: output
public static void output(@NotNull Element element, @NotNull File file, @NotNull Project project) throws IOException {
Writer writer = new OutputStreamWriter(new FileOutputStream(file), CharsetToolkit.UTF8);
try {
output(element, writer, project);
}
finally {
writer.close();
}
}
示例6: toString
/**
* Return a string listing of the settings for this
* XMLOutputter instance.
*
* @return a string listing the settings for this XMLOutputter instance
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < userFormat.lineSeparator.length(); i++) {
char ch = userFormat.lineSeparator.charAt(i);
switch (ch) {
case '\r': buffer.append("\\r");
break;
case '\n': buffer.append("\\n");
break;
case '\t': buffer.append("\\t");
break;
default: buffer.append("[" + ((int)ch) + "]");
break;
}
}
return (
"XMLOutputter[omitDeclaration = " + false + ", " +
"encoding = " + CharsetToolkit.UTF8 + ", " +
"omitEncoding = " + false + ", " +
"indent = '" + "\t" + "'" + ", " +
"expandEmptyElements = " + userFormat.expandEmptyElements + ", " +
"lineSeparator = '" + buffer.toString() + "', " +
"textMode = " + userFormat.mode + "]"
);
}
示例7: getCommitEncoding
/**
* Get commit encoding for the specified root
*
* @param project the context project
* @param root the project root
* @return the commit encoding or UTF-8 if the encoding is note explicitly specified
*/
public static String getCommitEncoding(final Project project, VirtualFile root) {
@NonNls String encoding = null;
try {
encoding = getValue(project, root, "i18n.commitencoding");
}
catch (VcsException e) {
// ignore exception
}
if (encoding == null || encoding.length() == 0) {
encoding = CharsetToolkit.UTF8;
}
return encoding;
}
示例8: getCharset
@Override
public String getCharset(@NotNull VirtualFile file, byte[] content) {
return CharsetToolkit.UTF8;
}
示例9: getCharset
@Nullable
@Override
public String getCharset(@NotNull VirtualFile file, @NotNull byte[] content) {
return CharsetToolkit.UTF8;
}
示例10: compute
@Override
public PsiFile compute() throws IOException {
String pdeContents = new String(FileUtil.loadBytes(pdeFile.getInputStream()), CharsetToolkit.UTF8);
return PsiFileFactory.getInstance(project).createFileFromText(pdeFile.getNameWithoutExtension(), JavaFileType.INSTANCE, pdeContents);
}
示例11: getCharset
@Override
public String getCharset(@org.jetbrains.annotations.NotNull VirtualFile file, @org.jetbrains.annotations.NotNull byte[] content) {
return CharsetToolkit.UTF8;
}
示例12: getCharset
@Override
public String getCharset(@NotNull VirtualFile file, @NotNull byte[] content) {
return CharsetToolkit.UTF8;
}
示例13: getCharset
@Nullable
@Override
public String getCharset(@NotNull VirtualFile file, @NotNull byte[] content) {
return CharsetToolkit.UTF8;
}
示例14: getCharset
@Override
public String getCharset(@NotNull VirtualFile file, @NotNull final byte[] content) {
return CharsetToolkit.UTF8;
}
示例15: getCharset
@Override
public String getCharset(@NotNull VirtualFile file, @NotNull byte[] content) {
return CharsetToolkit.UTF8;
}