简体   繁体   English

Java:从TCP流中读取XML文件而不将其写入磁盘

[英]Java: Reading XML file from a TCP stream without writing it to disk

I would like to send a XML file from a server to client. 我想将一个XML文件从服务器发送到客户端。 The XML file has been generated by the XMLEncoder class and contains some persistent objects. XML文件由XMLEncoder类生成,包含一些持久对象。

The client reads the XML file by using a XMLDecoder and storing the objects in a collection, but it's not necessary to write the file to disk. 客户端使用XMLDecoder读取XML文件并将对象存储在集合中,但不必将文件写入磁盘。 Is that possible? 那可能吗? If so, how could it be done? 如果是这样,怎么办呢? Thanks. 谢谢。

Is that possible? 那可能吗? If so, how could it be done? 如果是这样,怎么办呢?

Read the data from the socket instead of reading from a File. 从套接字读取数据而不是从文件中读取数据。 XMLDecoder takes an InputStream which can be the socket.getInputSteam(); XMLDecoder采用一个InputStream,它可以是socket.getInputSteam();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用java在不写入磁盘的情况下读取tar文件内容 - Reading tar file content without writing on disk using java 使用 Java 从 XML 文件中读取和写入 - Reading and Writing from an XML file in Java 如何使用Java或Kotlin将InputStream转换为RDD,而无需将流写入磁盘或将其全部读取到本地内存中? - How to convert InputStream to RDD with Java or Kotlin, without writing the stream to disk or reading it all into local memory? Java:从磁盘写入/读取映射 - Java: Writing/Reading a Map from disk 使用面向字节的流(例如FileInputStream / FileOutputStream)从文件读取int值/向文件写入int值是否会访问缓冲区/磁盘4次? - Will reading/writing an int value from/to a file using byte-oriented stream such as FileInputStream/FileOutputStream access the buffer/disk 4 times? 用Java读写XML文件的问题 - Issues with reading and writing an XML file in Java 在java中读取和编写xml - Reading and writing an xml in java 直接从URL将文件发布到REST api而不用Java写入磁盘 - To POST a file to a REST api directly from a URL without writing to disk in java 在Java中,如何从字符串创建文件而不将其写入磁盘? - In Java, how do I create a File from a String without writing it to disk? Java TCP:从网络读取输入 stream 时缓冲区下溢 - Java TCP: Buffer underflow when reading an input stream from the network
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM