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


Java FileUtil.loadBytes方法代碼示例

本文整理匯總了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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:MemoryResource.java

示例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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:LoadAllVfsStoredContentsAction.java

示例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;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:AbstractJavaFxPackager.java

示例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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:31,代碼來源:BuildSession.java

示例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();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:FileAttribute.java

示例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"));
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:40,代碼來源:ITNProxy.java

示例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();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:12,代碼來源:JBZipEntry.java

示例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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:36,代碼來源:ZipHandler.java

示例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();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:UrlUtil.java

示例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;
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:33,代碼來源:MavenArtifactUtil.java

示例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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:HgRepositoryReader.java

示例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);
}
 
開發者ID:mistodev,項目名稱:processing-idea,代碼行數:7,代碼來源:PdeConverter.java

示例13: getAll

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@Override
public byte[] getAll() throws IOException {
  return FileUtil.loadBytes(getInputStream());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:5,代碼來源:SanselanImageReaderSpi.java


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