本文整理匯總了Java中com.intellij.openapi.util.io.FileUtil.adaptiveLoadBytes方法的典型用法代碼示例。如果您正苦於以下問題:Java FileUtil.adaptiveLoadBytes方法的具體用法?Java FileUtil.adaptiveLoadBytes怎麽用?Java FileUtil.adaptiveLoadBytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.util.io.FileUtil
的用法示例。
在下文中一共展示了FileUtil.adaptiveLoadBytes方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: copyFromResource
import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
/**
* Copies content of resource to the given file
*
* @param file to copy to
* @param resourceUrl url of the resource to be copied
* @throws IOException if resource not found or copying failed
*/
public static void copyFromResource(@NotNull VirtualFile file, @NonNls @NotNull String resourceUrl) throws IOException {
InputStream out = VfsUtil.class.getResourceAsStream(resourceUrl);
if (out == null) {
throw new FileNotFoundException(resourceUrl);
}
try {
byte[] bytes = FileUtil.adaptiveLoadBytes(out);
file.setBinaryContent(bytes);
} finally {
out.close();
}
}
示例2: createFileFromResource
import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static void createFileFromResource(Project project, VirtualFile drawableDir, String name, String resourceFilePath)
throws IOException {
if (drawableDir.findChild(name) != null) {
return;
}
VirtualFile resFile = drawableDir.createChildData(project, name);
InputStream stream = AndroidModuleBuilder.class.getResourceAsStream(resourceFilePath);
try {
byte[] bytes = FileUtil.adaptiveLoadBytes(stream);
resFile.setBinaryContent(bytes);
}
finally {
stream.close();
}
}