Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8048293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:23:13+00:00 2026-06-05T06:23:13+00:00

I am using java for my server side application and phonegap for my client

  • 0

I am using java for my server side application and phonegap for my client side.i need to transfer huge image files when user login to my application.

I convert those image files to base64 format and put it into json object.when i send this json object to client side i am getting java out of memory error.

How to send those image files one by one in a single request since sending all files at a time causes java memory out of error.pl help me.

Here is my code:

File folderName = new File(processingFolder+"/"+f1[i].getName());
File[] folderFiles= folderName.listFiles();

for(int m=0;m<folderFiles.length;m++)
{
 System.out.println("folderFiles are:"+folderFiles[m]);
 String s1 = new String();
 File readfile = new File(folderFiles[m].toString());
 System.out.println(readfile.exists() + "!!");

 FileInputStream fis = new FileInputStream(readfile);
 ByteArrayOutputStream bos = new ByteArrayOutputStream();

 byte[] buf = new byte[1024];
 try {
     for (int readNum; (readNum = fis.read(buf)) != -1;) {
         bos.write(buf, 0, readNum); 
         //no doubt here is 0
         /*Writes len bytes from the specified byte array starting at offset 
         off to this byte array output stream.*/
     }
 }


 catch (IOException ex) {
 }
 byte[] bytes = bos.toByteArray();

 String result2 = Base64.encode( bytes );
 json1.put(folderFiles[m].getName(), result2);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:23:15+00:00Added an answer on June 5, 2026 at 6:23 am

    i found the solution for my question.
    i have send all the file names to the client side in json format. by looping the files names in the client side i send request to server and get a single file for each request. then i again write that file in my client side.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a client-server application using Java-RMI. Some server-side ressources have to be
I have a client server application where I am using java serversocket(server side) and
I'm using Java sockets for client - server application. I have a situation when
we have a java server-client application with an applet in the client side. our
I have some image files in server. I need to move or transfer the
I am using GWT for my client side application. I am not using GWT/Java
I have been developed a web application using java servlet at server side and
I am writing a server side application using Java. The server holds a number
I have a Java based web-application using Java Server Faces and Facelets. I am
I need to create 1000 server sockets using Java. Somewhere between creating 600 and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.