本文整理汇总了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);
}
}
示例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;
}
示例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();
}