java “解析文本文件或数据流”是什么意思,它是否适用于可序列化
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13924111/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
what does this mean 'Parsing a text file or data stream' and does it apply with serializables
提问by Lukeg101
This is my second post and I am getting used to the function of things on here now! this is more of a theory question for computer science but, my question is what does this mean?
这是我的第二篇文章,我现在已经习惯了这里的功能!这更像是计算机科学的一个理论问题,但是,我的问题是这是什么意思?
'Parsing a text file or data stream'
'解析文本文件或数据流'
This is an assignment and the books and web sources I have consulted are old or vague. I have implemented a serializable interface on a SinglyLinkedList which saves/loads the file to/from the disk so it can be transferred/edited and accessed later on. Does this qualify for a sufficient achievement of the rather vague requirement?
这是一项作业,我查阅过的书籍和网络资源都很陈旧或含糊不清。我在 SinglyLinkedList 上实现了一个可序列化的接口,该接口将文件保存到磁盘/从磁盘加载,以便以后可以传输/编辑和访问它。这是否足以满足相当模糊的要求?
things to note when considering this question:
考虑这个问题时需要注意的事项:
- this requirement is one of many for a project I am doing
- the Singly Linked List I am using is custom made - I know, the premade Java one is better, but I must show my skills
- all the methods work - I have tested them - its just a matter of documentation
- I am using ObjectOutputStream, FileOutputStream, ObjectInputStream and FileInputStream and the respective methods to read/write the Singly linked list object
- 这个要求是我正在做的一个项目的众多要求之一
- 我使用的单向链表是定制的——我知道,预制的 Java 更好,但我必须展示我的技能
- 所有的方法都有效——我已经测试过了——这只是一个文档问题
- 我正在使用 ObjectOutputStream、FileOutputStream、ObjectInputStream 和 FileInputStream 以及各自的方法来读/写单链表对象
I would appreciate the feedback
我会很感激的反馈
采纳答案by Jim Garrison
The process of "parsing" can be described as reading in a data stream of some sort and building an in-memory model or representation of the semantic content of that data, in order to facilitate performing some kind of transformation on the data.
“解析”的过程可以描述为读取某种类型的数据流并构建内存模型或该数据的语义内容的表示,以便于对数据执行某种转换。
Some examples:
一些例子:
- A compiler parses your source code to (usually) build an abstract syntax tree of the code, with the objective of generating object- (or byte-) code for execution by a machine.
- An interpreter does the same thing but the syntax tree is then directly used to control execution (some interpreters are a mashup of byte-code generators and virtual machines and may generate intermediate byte-code).
- A CSV parser reads a stream structured according to the rules of CSV (commas, quoting, etc) to extract the data items represented by each line in the file.
- A JSON or XML parser does a similar operation for JSON- or XML-encoded data, building an in-memory representation of the semantic values of the data items and their hierarchical inter-relationships.
- 编译器解析您的源代码以(通常)构建代码的抽象语法树,目的是生成供机器执行的对象(或字节)代码。
- 解释器做同样的事情,但语法树然后直接用于控制执行(一些解释器是字节码生成器和虚拟机的混搭,可能会生成中间字节码)。
- CSV 解析器读取根据 CSV 规则(逗号、引用等)构造的流,以提取文件中每一行表示的数据项。
- JSON 或 XML 解析器对 JSON 或 XML 编码的数据执行类似的操作,构建数据项语义值及其分层相互关系的内存表示。