當前位置: 首頁>>代碼示例>>Java>>正文


Java IFile.getCharset方法代碼示例

本文整理匯總了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;
}
 
開發者ID:Yakindu,項目名稱:solidity-ide,代碼行數:18,代碼來源:SolidityMarkerCreator.java

示例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;
	}
}
 
開發者ID:mnlipp,項目名稱:EclipseMinifyBuilder,代碼行數:24,代碼來源:GccMinifier.java

示例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;
}
 
開發者ID:liaoziyang,項目名稱:ContentAssist,代碼行數:18,代碼來源:ResourceMacro.java

示例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();
    }
}
 
開發者ID:liaoziyang,項目名稱:ContentAssist,代碼行數:22,代碼來源:XmlFileStream.java

示例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);
}
 
開發者ID:liaoziyang,項目名稱:ContentAssist,代碼行數:16,代碼來源:HistoryManager.java

示例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();
}
 
開發者ID:mnlipp,項目名稱:EclipseMinifyBuilder,代碼行數:10,代碼來源:YuiCssMinifier.java

示例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));
}
 
開發者ID:mnlipp,項目名稱:EclipseMinifyBuilder,代碼行數:15,代碼來源:YuiJsMinifier.java

示例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();
	}
}
 
開發者ID:Yakindu,項目名稱:solidity-ide,代碼行數:14,代碼來源:Source.java

示例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;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:28,代碼來源:QuickFixXpectMethod.java


注:本文中的org.eclipse.core.resources.IFile.getCharset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。