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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:53:12+00:00 2026-05-15T13:53:12+00:00

Im still teaching myself Java so I wanted to try to read a text

  • 0

Im still teaching myself Java so I wanted to try to read a text file and step 1) output it to console and step 2) write the contents to a new txt file.

Here is some code I have google’d to start with and it is reading the file, but when I output the line contents to the console I get the following (looks like its outputting in unicode or something… like every character as an extra byte associated to it….

ÿþFF□u□l□l□ □T□i□l□t□ □P□o□k□e□r□ <SNIP>

Here is what the first line of the file looks like when I open in via notepad:
Full Tilt Poker Game #xxxxxxxxxx: $1 + $0.20 Sit & Go (xxxxxxxx), Table 1 - 15/30 - No Limit Hold'em - 22:09:45 ET - 2009/12/26

Here is my code, do I need to specify the encoding to display txt file contents to the console? I assumed that simple text would be straight forward for java…but Im new and don’t understand much about how finicky java is yet.

EDIT: I dont know if it matters but Im using Eclipse as my IDE currently.

package readWrite;

import java.io.*;

public class Read {
    public static void main(String args[])
    {
        BufferedReader reader = null;
        try {
            reader = new BufferedReader(new FileReader("C:\\Users\\brian\\workspace\\downloads\\poker_text.txt"));
            String line = reader.readLine();

            while (line!=null) {
                // Print read line
                System.out.println(line);

                // Read next line for while condition
                line = reader.readLine();
            }

        } catch (IOException ioe) {
            System.out.println(ioe.getMessage());
        } finally {
            try { if (reader!=null) reader.close(); } catch (Exception e) {}
        }
    }
}
  • 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-15T13:53:12+00:00Added an answer on May 15, 2026 at 1:53 pm

    The ÿþ at the beginning appears to be a Byte Order Mark for a UTF-16 encoded file.

    http://en.wikipedia.org/wiki/Byte_order_mark#UTF-16

    You might need to read the file in a different manner so Java can convert those UTF-16 characters to something your System.out can display.

    Try something like this

    FileInputStream fis = new FileInputStream("filename");
    BufferedReader reader = new BufferedReader(new InputStreamReader(fis, "UTF-16"));
    

    OR

    Open up your text file in notepad again, and File/Save As. On the save screen (at least in windows 7) there is a pulldown with the encoding setting. Choose ANSI or UTF-8

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

Sidebar

Ask A Question

Stats

  • Questions 453k
  • Answers 453k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer A typical PriorityQueue implementation would use a Heap to get… May 15, 2026 at 9:35 pm
  • Editorial Team
    Editorial Team added an answer Reading through CodeIgniter Form Creating Library it seems that your… May 15, 2026 at 9:35 pm
  • Editorial Team
    Editorial Team added an answer The concept is not complicated, here's how I see it:… May 15, 2026 at 9:35 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.