0

First of all sorry if I'm repeating this question but I don't find any relevant solutions for my problem.

I'm facing difficulty in finding the way to solve the below issues.

1) I'm facing a scenario where I have to write more than 30 MB - 400 MB of data in a xml. When I'm using 'String' object to append the data to xml I'm getting 'OutOfMemory' exception.

After spending more time in doing R&D, I came to know that using 'Stream' will resolve this issue. But I'm not sure about this.

2) Once I constructed the xml, I have to send this data to the DMZ server using Android devices. As I know sending large amount of data using Http is difficult in this situation. In this case,

     a) Using FTP will be helpful in this scenario?
     b) Splitting the data into chunks of data and sending will be helpful?

Kindly let me know your suggestions. Thanks in advance.

macOsX
  • 447
  • 1
  • 9
  • 19
  • Splitting the file and/or compressing it (Huffman coding would be pretty good for an XML IMHO) will help a lot on the upload times – Machinarius Mar 26 '13 at 04:11

3 Answers3

2

i would consider zipping up the data before ftping it across.You could use a ZipOutputStream .

For the Out of Memory Exception, you could consider increasing the Heap Size. Check this : Increase heap size in Java

Can you post some values of heap size you tried, your code and some exception traces?

Community
  • 1
  • 1
DntFrgtDSemiCln
  • 1,259
  • 2
  • 16
  • 35
1

Use StAX or SAX. These can create XML of any size because they write XML parts they generate to OutputStream on the fly.

Evgeniy Dorofeev
  • 133,369
  • 30
  • 199
  • 275
0

What you should do is

First, use a XML parser to read and write data in XML format. it could be SAX or DOM. If data size is huge try CSV format it will take less space as you do not have to store XML tag.

Second, When creating output file make sure those are small small files.

third when sending over network, make sure you zipped everything.

And for god sake, don't eat up user mobile data cap for this design. Warn user about this file size and suggest him to use WiFi network.

minhaz
  • 4,233
  • 3
  • 33
  • 49