本文整理匯總了Java中org.eclipse.core.resources.IFile.getCharset方法的典型用法代碼示例。如果您正苦於以下問題:Java IFile.getCharset方法的具體用法?Java IFile.getCharset怎麽用?Java IFile.getCharset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IFile
的用法示例。
在下文中一共展示了IFile.getCharset方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getFileContent
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
private Map<Integer, String> getFileContent(IFile file) {
String fileEnding = FileUtil.getLineSeparator(file);
Map<Integer, String> content = Maps.newHashMap();
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(file.getContents(true), file.getCharset()));) {
String line = reader.readLine();
int lastLineNumber = 1;
while (line != null) {
content.put(lastLineNumber, line + fileEnding);
line = reader.readLine();
lastLineNumber++;
}
} catch (Exception e) {
e.printStackTrace();
}
return content;
}
示例2: GccMinifier
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public GccMinifier(MinifyBuilder builder, IFile srcFile, IFile destFile,
OutputStream out, IEclipsePreferences prefs)
throws IOException, CoreException {
super(builder);
this.srcFile = srcFile;
this.out = out;
this.outCharset = destFile.exists() ? destFile.getCharset() : "ascii";
console = builder.minifierConsole();
String optLevel = prefs.get(PrefsAccess.preferenceKey(
srcFile, MinifyBuilder.GCC_OPTIMIZATION),
MinifyBuilder.GCC_OPT_WHITESPACE_ONLY);
switch (optLevel) {
case MinifyBuilder.GCC_OPT_ADVANCED:
compilationLevel = CompilationLevel.ADVANCED_OPTIMIZATIONS;
break;
case MinifyBuilder.GCC_OPT_SIMPLE:
compilationLevel = CompilationLevel.SIMPLE_OPTIMIZATIONS;
break;
default:
compilationLevel = CompilationLevel.WHITESPACE_ONLY;
}
}
示例3: getEncoding
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Returns the encoding of the changed source code.
* @param elem the changed resource
* @return the encoding of the source code, or <code>null</code>
*/
private String getEncoding(IJavaElement elem) {
if (elem instanceof ICompilationUnit) {
ICompilationUnit cu = (ICompilationUnit)elem;
try {
IFile file = (IFile)cu.getCorrespondingResource();
return file.getCharset();
} catch (CoreException e) {
}
}
return null;
}
示例4: write
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
*
* Writes the content of the DOM instance into an XML file.
* @param doc the content of the DOM instance to be written
* @param path the full path indicating the file which the contents are written into
* @param file the input file
*/
public static void write(Document doc, String path, IFile file) {
try {
String encoding;
if (file == null) {
encoding = Charset.defaultCharset().name();
} else {
encoding = file.getCharset();
}
write(doc, path, encoding);
} catch (CoreException e) {
e.printStackTrace();
}
}
示例5: writeHistory
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Writes the operation history related to a file.
* @param file the file
*/
void writeHistory(IFile file) {
String encoding = null;
try {
if (file != null) {
encoding = file.getCharset();
}
} catch (CoreException e) {
}
writeHistory(encoding);
}
示例6: YuiCssMinifier
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public YuiCssMinifier(MinifyBuilder builder, IFile srcFile,
IFile destFile, OutputStream out, IEclipsePreferences prefs)
throws CoreException {
super(builder);
this.srcFile = srcFile;
this.inCharset = srcFile.getCharset();
this.out = out;
this.outCharset = destFile.exists() ? destFile.getCharset() : srcFile.getCharset();
}
示例7: YuiJsMinifier
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public YuiJsMinifier(MinifyBuilder builder, IFile srcFile, IFile destFile,
OutputStream out, IEclipsePreferences prefs)
throws IOException, CoreException {
super (builder);
preserveSemicolons = prefs.getBoolean(
PrefsAccess.preferenceKey(srcFile, MinifyBuilder.YUI_PRESERVE_SEMICOLONS), true);
disableOptimizations = prefs.getBoolean(
PrefsAccess.preferenceKey(srcFile, MinifyBuilder.YUI_DISABLE_OPTIMIZATIONS), true);
outCharset = destFile.exists() ? destFile.getCharset() : srcFile.getCharset();
writer = new OutputStreamWriter(out, outCharset);
compressor = new JavaScriptCompressor(new BufferedReader(
new InputStreamReader(srcFile.getContents(), srcFile.getCharset())),
new YuiMinifier.MinifyErrorHandler(srcFile));
}
示例8: Source
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
public Source(IFile file) {
String seperator = FileUtil.getLineSeparator(file);
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(file.getContents(true), file.getCharset()));) {
String line = reader.readLine();
while (line != null) {
content += line + seperator;
line = reader.readLine();
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例9: getContentForResourceUri
import org.eclipse.core.resources.IFile; //導入方法依賴的package包/類
/**
* Helper method to get the content of an resource at uri. Takes care of the encoding.
*
* @param uri
* URI to resource
* @return content as string
* @throws Exception
* in case of io or uri issues
*/
private String getContentForResourceUri(URI uri)
throws Exception {
String platformStr = uri.toString().replace("platform:/resource/", "");
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformStr));
java.io.InputStream fileStream = file.getContents();
java.util.Scanner s = new java.util.Scanner(fileStream, file.getCharset());
s.useDelimiter("\\A");
String content = s.hasNext() ? s.next() : "";
fileStream.close();
s.close();
return content;
}