package com.intellij.openapi.vfs;
import com.intellij.openapi.util.io.BufferExposingByteArrayInputStream;
+import com.intellij.openapi.util.io.FileUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.HashSet;
import java.util.Set;
}
visitor.afterChildrenVisited(file);
}
+
+ public static String loadText(@NotNull VirtualFile file) throws IOException{
+ InputStreamReader reader = new InputStreamReader(file.getInputStream(), file.getCharset());
+ try {
+ return new String(FileUtil.loadText(reader, (int)file.getLength()));
+ }
+ finally {
+ reader.close();
+ }
+ }
}
public class VfsUtil extends VfsUtilCore {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vfs.VfsUtil");
- public static String loadText(@NotNull VirtualFile file) throws IOException{
- InputStreamReader reader = new InputStreamReader(file.getInputStream(), file.getCharset());
- try {
- return new String(FileUtil.loadText(reader, (int)file.getLength()));
- }
- finally {
- reader.close();
- }
- }
-
public static void saveText(@NotNull VirtualFile file, @NotNull String text) throws IOException {
Charset charset = file.getCharset();
file.setBinaryContent(text.getBytes(charset.name()));