本文整理汇总了Java中com.intellij.openapi.util.io.FileUtil.loadBytes方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.loadBytes方法的具体用法?Java FileUtil.loadBytes怎么用?Java FileUtil.loadBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.util.io.FileUtil
的用法示例。
在下文中一共展示了FileUtil.loadBytes方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@NotNull
public static MemoryResource load(URL baseUrl,
@NotNull ZipFile zipFile,
@NotNull ZipEntry entry,
@Nullable Map<Attribute, String> attributes) throws IOException {
String name = entry.getName();
URL url = new URL(baseUrl, name);
byte[] content = ArrayUtil.EMPTY_BYTE_ARRAY;
InputStream stream = zipFile.getInputStream(entry);
if (stream != null) {
try {
content = FileUtil.loadBytes(stream, (int)entry.getSize());
}
finally {
stream.close();
}
}
return new MemoryResource(url, content, attributes);
}
示例2: processFile
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public boolean processFile(NewVirtualFile file) {
if (file.isDirectory() || file.is(VFileProperty.SPECIAL)) {
return true;
}
try {
DataInputStream stream = FSRecords.readContent(file.getId());
if (stream == null) return true;
byte[] bytes = FileUtil.loadBytes(stream);
totalSize.addAndGet(bytes.length);
count.incrementAndGet();
ProgressManager.getInstance().getProgressIndicator().setText(file.getPresentableUrl());
}
catch (IOException e) {
LOG.error(e);
}
return true;
}
示例3: startProcess
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private int startProcess(List<String> commands) {
try {
final Process process = new ProcessBuilder(CommandLineUtil.toCommandLine(commands)).start();
final String message = new String(FileUtil.loadBytes(process.getErrorStream()));
if (!StringUtil.isEmptyOrSpaces(message)) {
registerJavaFxPackagerError(message);
}
final int result = process.waitFor();
if (result != 0) {
final String explanationMessage = new String(FileUtil.loadBytes(process.getInputStream()));
if (!StringUtil.isEmptyOrSpaces(explanationMessage)) {
registerJavaFxPackagerError(explanationMessage);
}
}
return result;
}
catch (Exception e) {
registerJavaFxPackagerError(e);
return -1;
}
}
示例4: createFSDataStream
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Nullable
private static DataInputStream createFSDataStream(File dataStorageRoot, final long currentEventOrdinal) {
try {
final File file = new File(dataStorageRoot, FS_STATE_FILE);
byte[] bytes;
final InputStream fs = new FileInputStream(file);
try {
bytes = FileUtil.loadBytes(fs, (int)file.length());
}
finally {
fs.close();
}
final DataInputStream in = new DataInputStream(new ByteArrayInputStream(bytes));
final int version = in.readInt();
if (version != BuildFSState.VERSION) {
return null;
}
final long savedOrdinal = in.readLong();
if (savedOrdinal + 1L != currentEventOrdinal) {
return null;
}
return in;
}
catch (FileNotFoundException ignored) {
}
catch (Throwable e) {
LOG.error(e);
}
return null;
}
示例5: readAttributeBytes
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Nullable
public byte[] readAttributeBytes(VirtualFile file) throws IOException {
final DataInputStream stream = readAttribute(file);
if (stream == null) return null;
try {
int len = stream.readInt();
return FileUtil.loadBytes(stream, len);
}
finally {
stream.close();
}
}
示例6: postNewThread
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private static int postNewThread(String login, String password, ErrorBean error) throws Exception {
if (ourSslContext == null) {
ourSslContext = initContext();
}
Map<String, String> params = createParameters(login, password, error);
HttpURLConnection connection = post(new URL(NEW_THREAD_POST_URL), join(params));
int responseCode = connection.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_OK) {
throw new InternalEAPException(DiagnosticBundle.message("error.http.result.code", responseCode));
}
String response;
InputStream is = connection.getInputStream();
try {
byte[] bytes = FileUtil.loadBytes(is);
response = new String(bytes, ENCODING);
}
finally {
is.close();
}
if ("unauthorized".equals(response)) {
throw new NoSuchEAPUserException(login);
}
if (response.startsWith("update ")) {
throw new UpdateAvailableException(response.substring(7));
}
if (response.startsWith("message ")) {
throw new InternalEAPException(response.substring(8));
}
try {
return Integer.valueOf(response.trim()).intValue();
}
catch (NumberFormatException ex) {
throw new InternalEAPException(DiagnosticBundle.message("error.itn.returns.wrong.data"));
}
}
示例7: getData
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public byte[] getData() throws IOException {
if (size == -1) throw new IOException("no data");
final InputStream stream = getInputStream();
try {
return FileUtil.loadBytes(stream, (int)size);
}
finally {
stream.close();
}
}
示例8: contentsToByteArray
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@NotNull
@Override
public byte[] contentsToByteArray(@NotNull String relativePath) throws IOException {
FileAccessorCache.Handle<ZipFile> zipRef;
try {
zipRef = ourZipFileFileAccessorCache.get(this);
} catch (RuntimeException ex) {
final Throwable cause = ex.getCause();
if (cause instanceof IOException) throw (IOException)cause;
throw ex;
}
ZipFile zip = zipRef.get();
try {
ZipEntry entry = zip.getEntry(relativePath);
if (entry != null) {
InputStream stream = zip.getInputStream(entry);
if (stream != null) {
// ZipFile.c#Java_java_util_zip_ZipFile_read reads data in 8K (stack allocated) blocks
// no sense to create BufferedInputStream
try {
return FileUtil.loadBytes(stream, (int)entry.getSize());
}
finally {
stream.close();
}
}
}
}
finally {
zipRef.release();
}
return ArrayUtil.EMPTY_BYTE_ARRAY;
}
示例9: loadText
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public static String loadText(URL url) throws IOException {
final InputStream stream = new BufferedInputStream(URLUtil.openStream(url));
try {
return new String(FileUtil.loadBytes(stream), FileTemplate.ourEncoding);
}
finally {
stream.close();
}
}
示例10: createPluginDocument
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Nullable
private static MavenPluginInfo createPluginDocument(File file) {
try {
if (!file.exists()) return null;
ZipFile jar = new ZipFile(file);
try {
ZipEntry entry = jar.getEntry(MAVEN_PLUGIN_DESCRIPTOR);
if (entry == null) {
MavenLog.LOG.info(IndicesBundle.message("repository.plugin.corrupt", file));
return null;
}
InputStream is = jar.getInputStream(entry);
try {
byte[] bytes = FileUtil.loadBytes(is);
return new MavenPluginInfo(bytes);
}
finally {
is.close();
}
}
finally {
jar.close();
}
}
catch (IOException e) {
MavenLog.LOG.info(e);
return null;
}
}
示例11: readHashBytesFromFile
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@NotNull
private static byte[] readHashBytesFromFile(@NotNull File file) throws IOException {
byte[] bytes;
final InputStream stream = new FileInputStream(file);
try {
bytes = FileUtil.loadBytes(stream, 20);
}
finally {
stream.close();
}
return bytes;
}
示例12: compute
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
public PsiFile compute() throws IOException {
String pdeContents = new String(FileUtil.loadBytes(pdeFile.getInputStream()), CharsetToolkit.UTF8);
return PsiFileFactory.getInstance(project).createFileFromText(pdeFile.getNameWithoutExtension(), JavaFileType.INSTANCE, pdeContents);
}
示例13: getAll
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
public byte[] getAll() throws IOException {
return FileUtil.loadBytes(getInputStream());
}