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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:55:18+00:00 2026-05-23T12:55:18+00:00

I am using FileInputStream in Spring MVC to read a chunk of a file

  • 0

I am using FileInputStream in Spring MVC to read a chunk of a file into a byte[] buffer.

I then write (using FileCopyUtils.copy) the buffer to the response stream.

I notice that the response that is written to the stream (what the user receives) looks similar to the file, but there are blemishes.

  1. before the file data, there is a ‘2000’ (without quotes) at the top of the file.
  2. this ‘2000’ string is sporadically present throughout my file
  3. The file ends with a ‘0’

none of these exist in the original file that is being read from. Can anyone help me get rid of these so that I have an accurate output stream?

here’s an example of what my incorrect ouput looks like:

2000
a line of data
a line of data
a line of data
a line of data
a line of data
a line of data
a line o
2000
f data
a line of data
2000

a line of data
a line of data
0

it should just be:

a line of data
a line of data
a line of data
a line of data
a line of data
a line of data
a line of data
a line of data
a line of data
a line of data

Thanks!

  • 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-23T12:55:18+00:00Added an answer on May 23, 2026 at 12:55 pm

    my guess is that the stream is specified as a chunked transfer encoding and your simply reading it as is

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

Sidebar

Related Questions

I'm attempting to write a method that will read a properties file using Class.getResource(),
I'm working with Spring/Hibernet using NetBeans 6.9.1. I'm trying to read an Excel file
What is a better option (in terms of performance): copying a file using fileinputstream
I am using the below code to write a backup copy to SDCard and
i am trying to read an excel file using java. while compiling the program
I am writing to file in android and read from the same file using
I'm using Amazon .NET SDK, and adding file from my ASP.NET MVC app is
I am using Apache POI to read xlsx file, it works well. I have
I am reading in a text file using FileInputStream that puts the file contents
I'm trying to read a text file, i'm using fileImputStream, and reading all the

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.