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


Java VirtualFile.getInputStream方法代碼示例

本文整理匯總了Java中com.intellij.openapi.vfs.VirtualFile.getInputStream方法的典型用法代碼示例。如果您正苦於以下問題:Java VirtualFile.getInputStream方法的具體用法?Java VirtualFile.getInputStream怎麽用?Java VirtualFile.getInputStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.vfs.VirtualFile的用法示例。


在下文中一共展示了VirtualFile.getInputStream方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: read

import com.intellij.openapi.vfs.VirtualFile; //導入方法依賴的package包/類
@NotNull
static BsConfig read(@NotNull VirtualFile bsconfig) {
    try {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(bsconfig.getInputStream()))) {
            // Quick and dirty code to read json values from bsconfig
            StringBuilder content = new StringBuilder();
            reader.lines().forEach(line -> content.append(line.trim()));
            // extract bs dependencies
            Matcher matcher = DEPS_REGEXP.matcher(content.toString());

            String[] deps = null;
            if (matcher.matches()) {
                String[] tokens = matcher.group(1).split(",");
                deps = new String[tokens.length];
                for (int i = 0; i < tokens.length; i++) {
                    String token = tokens[i].trim();
                    deps[i] = token.substring(1, token.length() - 1) + "/lib";
                }
            }

            return new BsConfig(deps);
        }
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:reasonml-editor,項目名稱:reasonml-idea-plugin,代碼行數:27,代碼來源:BsConfig.java

示例2: getLineNumber

import com.intellij.openapi.vfs.VirtualFile; //導入方法依賴的package包/類
private static int getLineNumber(VirtualFile virtualFile, TextRange textRange) {
    try {
        BufferedReader br = new BufferedReader(new InputStreamReader(virtualFile.getInputStream()));
        String line;
        int pos = 0;
        int lineNumber = 0;

        while ((line = br.readLine()) != null) {
            pos += line.length() + 1; //+1 for new line
            lineNumber++;

            if (pos >= textRange.getStartOffset()) {
                return lineNumber;
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return -1;
}
 
開發者ID:BFergerson,項目名稱:JNomad-Plugin,代碼行數:21,代碼來源:JNomadQueryVisitor.java

示例3: read

import com.intellij.openapi.vfs.VirtualFile; //導入方法依賴的package包/類
@NotNull
public static String read(@NotNull VirtualFile file) throws IOException
{
    InputStreamReader reader = new InputStreamReader(file.getInputStream());
    BufferedReader bufReader = new BufferedReader(reader);
    StringBuilder builder = new StringBuilder();
    String line = bufReader.readLine();
    while (line != null)
    {
        builder.append(line).append("\n");
        line = bufReader.readLine();
    }
    return builder.toString();
}
 
開發者ID:miche-atucha,項目名稱:deps-checker,代碼行數:15,代碼來源:VirtualFileHelper.java


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