本文整理匯總了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();
}