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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:04:25+00:00 2026-06-09T12:04:25+00:00

From GWT I read a text file myFile.txt as per below. The issue is

  • 0

From GWT I read a text file “myFile.txt” as per below. The issue is that I get different results in the “input” string depending on the server:

  • If I run in from Eclipse Indigo local server (debugging), “input” includes at the end characters “\r” and “\n”.
  • If I run it from Google App Engine, “input” includes at the end character “\n” only, so one character less in input.length.

Why does this happen, and how can I have the same behaviour?

Thanks

String input=readFromFile("myFile.txt");

public String readFromFile(String fileName) {
  File file = new File(fileName);
  StringBuffer contents = new StringBuffer();
  BufferedReader reader = null;
  try {
    reader = new BufferedReader(new FileReader(file));
    String text = null;
    while ((text = reader.readLine()) != null) {
    contents.append(text).append(System.getProperty("line.separator"));
    }
  } catch (FileNotFoundException e) {
    e.printStackTrace();
  } catch (IOException e) {
    e.printStackTrace();
  } finally {
    try {
      if (reader != null) {
        reader.close();
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  contents.deleteCharAt(contents.length()-2); // Remove to make it work in GAE
  contents.deleteCharAt(contents.length()-1);
  return contents.toString();
}
  • 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-09T12:04:27+00:00Added an answer on June 9, 2026 at 12:04 pm

    Because line separators are different on different OSes. This is what System.getProperty("line.separator") does.

    On Windows it’s \r\n\ (two chars), while on Linux it’s \n (one char). See here..

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

Sidebar

Related Questions

Aside from the official GWT blog, which GWT blogs do you read?
I am using MenuBar from GWT showcase. I want to add text in the
I want to access the text elements inside this textbox in GWT from the
I have a simple java applet that is invoked from gwt application. Is there
I have read a lot of gwt-mvp questions that are asked here, but since
What's the best way to read properties from the GWT host page? I'm trying
I'm trying to send a file from an applet to my server GWT. In
Can I access spring bean that exposed using http invoker (server) from GWT application
I am trying to do a file upload from gwt-ext without bringing up the
I read some var from my HTML-Page using GWT Dictionary. The var looks like

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.