2

In my applet, I am having One Stream that contains a number of XML files. Now i am sending this stream to server side and i want to retrieve those multiple files from that Stream.

I can do the same by making a zip file of multiple XML files in my applet code and then writing it to Stream and then on the server side make a zip file from Stream and unzip it.

But i don't want this.Is there any other way to do it?

Ankit Sharma
  • 1,569
  • 3
  • 19
  • 31
  • Is you have to read files one by one using single stream? – Pandiyan Cool Jul 30 '13 at 12:43
  • I have to read all the files and save it at particular location on server. – Ankit Sharma Jul 30 '13 at 12:53
  • Ok how will you select those files? From particular Folder path or else? – Pandiyan Cool Jul 30 '13 at 12:54
  • On server side, i am making one stream from multiple streams(for each file) and then using that stream at client side in applet code. File locations are different.It is in different-2 folder. – Ankit Sharma Jul 30 '13 at 13:09
  • What type of stream do you use? Post your code please – Luca Jul 30 '13 at 13:19
  • since they are text files (xml) you could use a custom row at the end of file, this line could write the file name and destination folder. – Luca Jul 30 '13 at 13:22
  • @Luca I tried this way too, but the problem with this approach is I have to create one file that is having all other xml files then i have to go through with this single file to create multiple xml files at receiver side. Don't you think it will be slow, if lots of xml files will be there? and it is just like a zip (having all files in one package) then it will be better to use zip file. Correct me if i am wrong. – Ankit Sharma Jul 31 '13 at 03:56

1 Answers1

0

use your own XML tags to delimit the files:

<file name="directoryA/folderB/filename">
</file>

and put the XML for the file itself inside those tags. Make the tag name more elaborate if you're worried about "file" being used within the XML.

arcy
  • 12,845
  • 12
  • 58
  • 103
  • you want one stream -- think of the stream as if it were one file, containing information for multiple files. Use your own tags at the beginning and end of each individual file to delimit that file, then your receiver can take the information back apart. If you ever want to store that, it has all the advantages of XML: (sort-of)-human-readable, etc. – arcy Jul 30 '13 at 14:37
  • Means you are telling create one XML that will have all other XMLs within some special tag and then send stream form of that single XML to receiver and get whole info back by using separator tag. If it is so then it will be better to use zip format instead of single XML.That will be much faster as compared to single XML. Right? – Ankit Sharma Jul 31 '13 at 03:43
  • of course. Except in the original question, you said "I don't want this" to the option of creating a zip file and unzipping it at the server end. If what you want is the fastest way to do this, then you should say why you don't want this; if you want this, I don't know why you posted a question at all. – arcy Jul 31 '13 at 13:37
  • I posted this question to get a better alternative way to do this better way as compared to zip method and i am not telling what you have suggested is wrong. But it not better than zip method. – Ankit Sharma Jul 31 '13 at 14:18
  • Better is extremely subjective. If you have reasons why you don't want to use zip, or performance parameters which you want to meet, then put them into your question. If all you do is say "I don't want X", then you get alternatives to X. If you don't say what constraints you have, then you're just wasting people's time, as you seem to have wasted mine. Good luck with your problem. – arcy Jul 31 '13 at 14:38
  • Sorry for wasting your time and thanks for your suggestions. Next time I ll keep these things in mind while asking. – Ankit Sharma Aug 01 '13 at 05:16