热门标签 | 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中java.lang.NoSuchMethodError.getMessage()方法的一些代码示例,展示了NoSuchMethodErr ... [详细]
  • 个人学习使用:谨慎参考1Client类importcom.thoughtworks.gauge.Step;importcom.thoughtworks.gauge.T ... [详细]
  • 纠正网上的错误:自定义一个类叫java.lang.System/String的方法
    本文纠正了网上关于自定义一个类叫java.lang.System/String的错误答案,并详细解释了为什么这种方法是错误的。作者指出,虽然双亲委托机制确实可以阻止自定义的System类被加载,但通过自定义一个特殊的类加载器,可以绕过双亲委托机制,达到自定义System类的目的。作者呼吁读者对网上的内容持怀疑态度,并带着问题来阅读文章。 ... [详细]
  • 阿,里,云,物,联网,net,core,客户端,czgl,aliiotclient, ... [详细]
  • Spring特性实现接口多类的动态调用详解
    本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
  • 前景:当UI一个查询条件为多项选择,或录入多个条件的时候,比如查询所有名称里面包含以下动态条件,需要模糊查询里面每一项时比如是这样一个数组条件:newstring[]{兴业银行, ... [详细]
  • 先看官方文档TheJavaTutorialshavebeenwrittenforJDK8.Examplesandpracticesdescribedinthispagedontta ... [详细]
  • 本文介绍了Swing组件的用法,重点讲解了图标接口的定义和创建方法。图标接口用来将图标与各种组件相关联,可以是简单的绘画或使用磁盘上的GIF格式图像。文章详细介绍了图标接口的属性和绘制方法,并给出了一个菱形图标的实现示例。该示例可以配置图标的尺寸、颜色和填充状态。 ... [详细]
  • 基于Socket的多个客户端之间的聊天功能实现方法
    本文介绍了基于Socket的多个客户端之间实现聊天功能的方法,包括服务器端的实现和客户端的实现。服务器端通过每个用户的输出流向特定用户发送消息,而客户端通过输入流接收消息。同时,还介绍了相关的实体类和Socket的基本概念。 ... [详细]
  • 重入锁(ReentrantLock)学习及实现原理
    本文介绍了重入锁(ReentrantLock)的学习及实现原理。在学习synchronized的基础上,重入锁提供了更多的灵活性和功能。文章详细介绍了重入锁的特性、使用方法和实现原理,并提供了类图和测试代码供读者参考。重入锁支持重入和公平与非公平两种实现方式,通过对比和分析,读者可以更好地理解和应用重入锁。 ... [详细]
  • 本文介绍了Android中的assets目录和raw目录的共同点和区别,包括获取资源的方法、目录结构的限制以及列出资源的能力。同时,还解释了raw目录中资源文件生成的ID,并说明了这些目录的使用方法。 ... [详细]
  • ***byte(字节)根据长度转成kb(千字节)和mb(兆字节)**parambytes*return*publicstaticStringbytes2kb(longbytes){ ... [详细]
  • 本文介绍了解决java开源项目apache commons email简单使用报错的方法,包括使用正确的JAR包和正确的代码配置,以及相关参数的设置。详细介绍了如何使用apache commons email发送邮件。 ... [详细]
  • 本文介绍了关于Java异常的八大常见问题,包括异常管理的最佳做法、在try块中定义的变量不能用于catch或finally的原因以及为什么Double.parseDouble(null)和Integer.parseInt(null)会抛出不同的异常。同时指出这些问题是由于不同的开发人员开发所导致的,不值得过多思考。 ... [详细]
  • 学习Java异常处理之throws之抛出并捕获异常(9)
    任务描述本关任务:在main方法之外创建任意一个方法接收给定的两个字符串,把第二个字符串的长度减1生成一个整数值,输出第一个字符串长度是 ... [详细]
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社区 版权所有