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

  • Home
  • SEARCH
  • 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 6109283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:23:14+00:00 2026-05-23T14:23:14+00:00

byte[] serObj = getBytesFromFile(file); final byte[] CLRF = { ‘\r’, ‘\n’ }; Base64 encoded

  • 0
byte[] serObj = getBytesFromFile(file);
final byte[] CLRF = { '\r', '\n' };
Base64 encoded = new Base64 (72,CLRF);
System.out.println(encoded.encodeBase64String(serObj));

I am having problems formatting the output, which currently displays as a single line, and not according to the args in constructor. It is supposed to be a line with 72 chars and followed by CLRF and the next line. Can someone point out what’s wrong with the code? Also, how could I manually append/add a newline char within a String? I tried using a char counter, but I am stuck on how to add the \n once the counter reaches the 72nd char.

public static int count(Reader in) throws IOException {
char[] buffer = new char[4096];
int count = 0;
int len;
while((len = in.read(buffer)) != -1) {
    count += len;
}
    return count;
}
  • 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-05-23T14:23:15+00:00Added an answer on May 23, 2026 at 2:23 pm

    The encodeBase64String(byte[]) method you are calling is a static method, so the Base64 instance that you created is not being used by the method call.

    You should be using the encodeToString(byte[]) method, which is an instance method.

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

Sidebar

Related Questions

byte[] bytes = new byte[] { 1, -1 }; System.out.println(Arrays.toString(new String(bytes, UTF-8).getBytes(UTF-8))); System.out.println(Arrays.toString(new String(bytes,
byte[] data = (byte[])opBinding.execute(); PrintWriter out = new PrintWriter(outputStream); out.println(data); out.flush(); out.close(); but instead
byte[] b1 = null; byte[] b2 = null; System.out.println(b1 + b2); // 1 System.out.println(
public byte[] imageToByteArray(System.Drawing.Image imageIn) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = Document; //
public final byte[] getParam(String commandName,String memLocation,String dataId){ byte[] result = new byte[9]; //GET_PARAM, RAM,WATER_OUTLET_TEMP
byte[] imageBytes = Convert.FromBase64String(base64String); MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length); How will I
byte[] mediaBytes = Convert.FromBase64String(<<strings>>); XpsDocument doc; ms = new MemoryStream(mediaBytes, 0, mediaBytes.Length); Uri DocumentUri
I have a byte array in memory, read from a file. I would like
I have a byte[] array, the contents of which represent a TIFF file (as
I am writing a StringOutputStream class in Java because I need the pre-Base64-encoded data

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.