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 8969545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:36:27+00:00 2026-06-15T17:36:27+00:00

I want to display the image received by the client and show that image

  • 0

I want to display the image received by the client and show that image on the server.. but I have kept the image part to be done later and initially just receive the inputstream and print it.

The problem is it is accepting the client request but doesnot print the decodedstring i.e decodedString = Base64.decodeBase64(base64Code);

Here’s the code for the server

import java.net.*;
import java.io.*;

import org.apache.commons.codec.binary.Base64;
import java.awt.*;

import javax.swing.*;


public class server {
private static DataInputStream dataInputStream;


private static DataOutputStream dataOutputStream;

public static void main(String[] args) throws IOException {
// create socket
ServerSocket servsock = new ServerSocket(14789);

Socket sock = servsock.accept();
dataInputStream = new DataInputStream(sock.getInputStream());
dataOutputStream = new DataOutputStream(sock.getOutputStream());
System.out.println("Accepted connection : " + sock);


String base64Code = dataInputStream.readUTF();

byte[] decodedString = null;

decodedString =  Base64.decodeBase64(base64Code);
System.out.println("Image Successfully Manipulated!" + decodedString);

if (dataOutputStream != null) {
try {
dataOutputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

if (dataInputStream != null) {
try {
dataInputStream.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}



sock.close();
}


public static String encodeImage(byte[] imageByteArray) {
return Base64.encodeBase64String(imageByteArray);
}
}

Any help will be highly appreciated.

  • 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-15T17:36:28+00:00Added an answer on June 15, 2026 at 5:36 pm

    You cant just print array of bytes, the code

    System.out.println("Image Successfully Manipulated!" + decodedString);
    

    print something like

    Image Successfully Manipulated![B@1cd2e5f
    

    If you want to print byte array as String you should convert byte array to hex String, for example like this:

    public static String byteArrayToHexString(byte[] b)
    {
        StringBuffer sb = new StringBuffer(b.length * 2);
        for (int i = 0; i < b.length; i++)
        {
            int v = b[i] & 0xff;
            if (v < 16)
            {
                sb.append('0');
            }
            sb.append(Integer.toHexString(v));
        }
        return sb.toString().toUpperCase();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a code that will show the image got from a local client.
I want to display an image using this php script on my server. $file
I want to display image in TextView with text, I had used Html.ImageGetter but
i want to display an image besides the text in table cell. i have
I have a MOSS 2007 site. I want to display the display image (or
I am trying to receive the image form Server and want to display it
I want display an image instead of downloading it. I have image in my
I want to display image after textbox for validation (tick and cross) But when
I want to display the image like first image but my images are displaying
I'm new to HTML and want to display image shown on left. I have

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.