Java I / O流过滤器的示例 [英] Examples of Java I/O Stream Filters

查看:176
本文介绍了Java I / O流过滤器的示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找示例代码,演示如何创建可理解二进制数据的过滤器。例子中的链接非常感谢。

解决方案

举个好例子,我建议看一下<一个href =http://java.sun.com/javase/6/docs/api/java/io/DataInputStream.html =nofollow noreferrer> java.io.DataInputStream 。这个类向您展示了一种从二进制数据中解码原始类型和字符串的方法,从中可以生成更复杂的结构。

当然,其他应用程序可能会选择使用其他编码。例如, ASN.1区分编码规则用于公共关键基础设施应用 Lucene提供了很好的文档,它的文件格式是专为简洁而设计的。 / p>

如果您有Sun JDK,请在其顶部目录中查找src.zip。大多数IDE将会告诉你核心Java类的源代码,如果你告诉他们在哪里可以找到这个文件。

I am looking for example code that demonstrates how to create a filter that understands binary data. Links to examples are greatly appreciated.

解决方案

For a good example, I'd suggest taking a look at the source code for java.io.DataInputStream. This class shows you one way to decode primitive types and character strings from "binary" data, from which more complex structures can be produced.

Of course, other applications might choose to use other encodings. For example, the ASN.1 "distinguished encoding rules" are used for Public Key Infrastructure applications. Lucene provides good documentation for its file format, which is designed for compactness.

If you have the Sun JDK, look in its top directory for "src.zip". Most IDEs will show you the source code for the core Java classes if you tell them where to find this file.

这篇关于Java I / O流过滤器的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆