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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:35:22+00:00 2026-06-16T10:35:22+00:00

I have below readfile() java function to read .htm files private String readfile(String inputDoc)

  • 0

I have below readfile() java function to read .htm files

private String readfile(String inputDoc) throws IOException {
    FileInputStream fis = null;
    InputStreamReader isr = null;
    String text = null;
    //open input stream to file
    fis = new FileInputStream(inputDoc);
    isr = new InputStreamReader(fis, "UTF-8");
    StringBuffer buffer = new StringBuffer();
    int c;
    while( (c = isr.read()) != -1 ) {
        buffer.append((char)c);
    }
    text = buffer.toString();
    isr.close();
    return text;
}

Here is example snippet of input doc

<?xml version="1.0" encoding="utf-8"?><html>

<head>

For some reason text string returned from readfile() is <?xml version="1.0" encoding="utf-8"?><html>\r\r\n<head>

but I expect it to be <?xml version="1.0" encoding="utf-8"?><html>\r\n<head>

as it is outlined here newline char in windows \r\n

I ran above function in IntelliJ Idea on Windows 7. (IDEA default encoding is set to UTF-8)

Does anyone know why I get this weird result from readfile(String inputDoc) function for newline

  • 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-16T10:35:23+00:00Added an answer on June 16, 2026 at 10:35 am

    You get this because it is like this in the input file. Try to open the input file in a hex editor to verify.

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

Sidebar

Related Questions

I have a function as below int* readFile(string InputPath) { int *myvar = new
I have below code: class Program { static void Main(string[] args) { Task[] tasks
I have below string String str=select * from m_menus; select * from m_roles; I
I have some simple, working code to read and write files: openFile = open("filepath",
i have read file function which will read a txt file. after i read
Suppose I have a text file with data like below, I want to read
I have a class as outlined below: class InputReader { public: typedef void (*handler)(std::string,
I have below string in javascript var output = '<?xml version=1.0 encoding=UTF-8 standalone=yes?><abc><xyz><xyzResponse><URL>http%3A%2F%2Flocalhost%3A8080%2Fnet%2Fxyz.do%3Fpartner%3Ddummy%26id%3Dba0e245f-ae67-40b6-986d-3242acea4c04</URL><StatusMsg>SUCCESS</StatusMsg><ID>hello.com</ID><AID>test</AID></xyzResponse></xyz></abc>'; I
I have written a function that attempts to read a child process's command line
i have below code snippet in dao String GET_CUSTOMER=SELECT * from customer where custName=:custName

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.