热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.openimaj.io.IOUtils.readable()方法的使用及代码示例

本文整理了Java中org.openimaj.io.IOUtils.readable()方法的一些代码示例,展示了IOUtils.readable()

本文整理了Java中org.openimaj.io.IOUtils.readable()方法的一些代码示例,展示了IOUtils.readable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IOUtils.readable()方法的具体详情如下:
包路径:org.openimaj.io.IOUtils
类名称:IOUtils
方法名:readable

IOUtils.readable介绍

[英]Check whether an InputStream can be read by an instantiated class based on it's binary and ascii headers. Buffered so the stream can be reset after the check.
[中]检查一个实例化的类是否可以根据其二进制和ascii头读取InputStream。缓冲,以便检查后可以重置流。

代码示例

代码示例来源:origin: openimaj/openimaj

/**
* Check whether an input stream starts with a header string. Calls the
* byte[] version of this function
*
* @see IOUtils#isBinary(BufferedInputStream, byte[])
*
* @param bis
* the input stream
* @param header
* the header
* @return whether the stream starts with the string
* @throws IOException
* error reading stream
*/
public static boolean readable(BufferedInputStream bis, String header) throws IOException {
return readable(bis, header.getBytes());
}

代码示例来源:origin: openimaj/openimaj

/**
* Check whether a file is readable by checking it's first bytes contains
* the header. Converts the header to a byte[] and calls the byte[] version
* of this method
*
* @see IOUtils#readable(File, byte[])
*
* @param f
* the file to check
* @param header
* the header to check with
* @return does this file contain this header
* @throws IOException
* error reading file
*/
public static boolean readable(File f, String header) throws IOException {
return readable(f, header.getBytes());
}

代码示例来源:origin: openimaj/openimaj

/**
* Check whether an InputStream can be read by an instantiated class based
* on it's binary and ascii headers. Buffered so the stream can be reset
* after the check.
*
* @param
* instance type expected
* @param bis
* the stream
* @param cls
* the class to instantiate and check
* @return can an object be read from this stream of the class type
* @throws IOException
* error reading stream
*/
public static boolean readable(BufferedInputStream bis, Class cls) throws IOException
{
final InternalReadable obj = newInstance(cls);
return (obj instanceof ReadableBinary && readable(bis, ((ReadableBinary) obj).binaryHeader())) ||
(obj instanceof ReadableASCII && readable(bis, ((ReadableASCII) obj).asciiHeader()));
}

代码示例来源:origin: openimaj/openimaj

/**
* Check whether a given file is readable by a given Writeable class.
* Instantiates the class to get it's binary and ascii header which is then
* passed to the byte[] version of this method
*
* @see Readable#asciiHeader()
*
* @param
* instance type expected
* @param f
* the file to check
* @param cls
* the class to instantiate the Readable object
* @return is file readable by a given class
* @throws IOException
* error reading file
*/
public static boolean readable(File f, Class cls) throws IOException {
final InternalReadable obj = newInstance(cls);
return (obj instanceof ReadableBinary && readable(f, ((ReadableBinary) obj).binaryHeader())) ||
(obj instanceof ReadableASCII && readable(f, ((ReadableASCII) obj).asciiHeader()));
}

代码示例来源:origin: openimaj/openimaj

/**
* Guess the type of the clusters based on the file header
*
* @param oldout
* @return guessed type
*/
public static ClusterTypeOp sniffClusterType(BufferedInputStream oldout) {
for (final ClusterType c : ClusterType.values()) {
for (final Precision p : Precision.values()) {
final ClusterTypeOp opts = (ClusterTypeOp) c.getOptions();
opts.precision = p;
try {
if (IOUtils.readable(oldout, opts.getClusterClass())) {
return opts;
}
} catch (final Exception e) {
e.printStackTrace();
}
}
}
return null;
}
}

代码示例来源:origin: openimaj/openimaj

/**
* Guess the type of the clusters based on the file header
*
* @param oldout
* @return guessed type
*/
public static ClusterTypeOp sniffClusterType(File oldout) {
for (final ClusterType c : ClusterType.values()) {
for (final Precision p : Precision.values()) {
final ClusterTypeOp opts = (ClusterTypeOp) c.getOptions();
opts.precision = p;
try {
if (IOUtils.readable(oldout, opts.getClusterClass()))
return opts;
} catch (final Exception e) {
}
}
}
return null;
}

推荐阅读
  • 纠正网上的错误:自定义一个类叫java.lang.System/String的方法
    本文纠正了网上关于自定义一个类叫java.lang.System/String的错误答案,并详细解释了为什么这种方法是错误的。作者指出,虽然双亲委托机制确实可以阻止自定义的System类被加载,但通过自定义一个特殊的类加载器,可以绕过双亲委托机制,达到自定义System类的目的。作者呼吁读者对网上的内容持怀疑态度,并带着问题来阅读文章。 ... [详细]
  • 个人学习使用:谨慎参考1Client类importcom.thoughtworks.gauge.Step;importcom.thoughtworks.gauge.T ... [详细]
  • Java序列化对象传给PHP的方法及原理解析
    本文介绍了Java序列化对象传给PHP的方法及原理,包括Java对象传递的方式、序列化的方式、PHP中的序列化用法介绍、Java是否能反序列化PHP的数据、Java序列化的原理以及解决Java序列化中的问题。同时还解释了序列化的概念和作用,以及代码执行序列化所需要的权限。最后指出,序列化会将对象实例的所有字段都进行序列化,使得数据能够被表示为实例的序列化数据,但只有能够解释该格式的代码才能够确定数据的内容。 ... [详细]
  • [大整数乘法] java代码实现
    本文介绍了使用java代码实现大整数乘法的过程,同时也涉及到大整数加法和大整数减法的计算方法。通过分治算法来提高计算效率,并对算法的时间复杂度进行了研究。详细代码实现请参考文章链接。 ... [详细]
  • Ihavethefollowingonhtml我在html上有以下内容<html><head><scriptsrc..3003_Tes ... [详细]
  • 学习Java异常处理之throws之抛出并捕获异常(9)
    任务描述本关任务:在main方法之外创建任意一个方法接收给定的两个字符串,把第二个字符串的长度减1生成一个整数值,输出第一个字符串长度是 ... [详细]
  • 本文介绍了Swing组件的用法,重点讲解了图标接口的定义和创建方法。图标接口用来将图标与各种组件相关联,可以是简单的绘画或使用磁盘上的GIF格式图像。文章详细介绍了图标接口的属性和绘制方法,并给出了一个菱形图标的实现示例。该示例可以配置图标的尺寸、颜色和填充状态。 ... [详细]
  • Java太阳系小游戏分析和源码详解
    本文介绍了一个基于Java的太阳系小游戏的分析和源码详解。通过对面向对象的知识的学习和实践,作者实现了太阳系各行星绕太阳转的效果。文章详细介绍了游戏的设计思路和源码结构,包括工具类、常量、图片加载、面板等。通过这个小游戏的制作,读者可以巩固和应用所学的知识,如类的继承、方法的重载与重写、多态和封装等。 ... [详细]
  • 本文介绍了一个Java猜拳小游戏的代码,通过使用Scanner类获取用户输入的拳的数字,并随机生成计算机的拳,然后判断胜负。该游戏可以选择剪刀、石头、布三种拳,通过比较两者的拳来决定胜负。 ... [详细]
  • Java容器中的compareto方法排序原理解析
    本文从源码解析Java容器中的compareto方法的排序原理,讲解了在使用数组存储数据时的限制以及存储效率的问题。同时提到了Redis的五大数据结构和list、set等知识点,回忆了作者大学时代的Java学习经历。文章以作者做的思维导图作为目录,展示了整个讲解过程。 ... [详细]
  • 猜字母游戏
    猜字母游戏猜字母游戏——设计数据结构猜字母游戏——设计程序结构猜字母游戏——实现字母生成方法猜字母游戏——实现字母检测方法猜字母游戏——实现主方法1猜字母游戏——设计数据结构1.1 ... [详细]
  • 前景:当UI一个查询条件为多项选择,或录入多个条件的时候,比如查询所有名称里面包含以下动态条件,需要模糊查询里面每一项时比如是这样一个数组条件:newstring[]{兴业银行, ... [详细]
  • Android工程师面试准备及设计模式使用场景
    本文介绍了Android工程师面试准备的经验,包括面试流程和重点准备内容。同时,还介绍了建造者模式的使用场景,以及在Android开发中的具体应用。 ... [详细]
  • 基于Socket的多个客户端之间的聊天功能实现方法
    本文介绍了基于Socket的多个客户端之间实现聊天功能的方法,包括服务器端的实现和客户端的实现。服务器端通过每个用户的输出流向特定用户发送消息,而客户端通过输入流接收消息。同时,还介绍了相关的实体类和Socket的基本概念。 ... [详细]
  • 本文介绍了Android中的assets目录和raw目录的共同点和区别,包括获取资源的方法、目录结构的限制以及列出资源的能力。同时,还解释了raw目录中资源文件生成的ID,并说明了这些目录的使用方法。 ... [详细]
author-avatar
书友48169582
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有