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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:01:40+00:00 2026-05-21T03:01:40+00:00

I have problem with my Java program. How I read xml -file which has

  • 0

I have problem with my Java program. How I read xml -file which has “UTF-8” encoding. Program works correctly in Kubuntu but I doesn’t work in Windows. Both OSes is writing xml -file correctly but parsing gives exception error in Windows.

String XMLFile = "ÄÄKKÖSET.xml"
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File (XMLFile));

Here is xml -file I need to parse:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<deck created="04/04/2011">
  <title>ääkköset</title>
  <code>ÄÄKKÖSET</code>
  <description>ääkköset</description>
  <author>ääkköset</author>
  <cards nextCardID="1">
    <card color="#1364F9" id="0">
      <question>ÄÄKKÖSET</question>
      <answer>ÄÄKKÖSET</answer>
    </card>
  </cards>
</deck>

How do I get to read xml -file with Java in Windows without getting I get “IOException: Invalid byte 2 of 2-byte UTF-8 sequence.” -error?

Thanks in advance!

  • 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-21T03:01:40+00:00Added an answer on May 21, 2026 at 3:01 am

    Invalid byte 2 of 2-byte UTF-8 sequence.

    Your XML document has not been saved as UTF-8, the parser detects this (because not all byte sequences are legal UTF-8) and throws an error.

    The solution is to save the file as UTF-8. It is not enough to declare the document as UTF-8 – the bytes the data is encoded to must match this declaration. By default, many text editors on Windows will default to saving data as ANSI.

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

Sidebar

Related Questions

I have utf-8 file which I want to read and display in my java
I'm writing a little Java program (it's an ImageJ plugin, but the problem is
I have a problem using the Java search function in Eclipse on a particular
I have a little Java problem I want to translate to Python. Therefor I
I have the following problem in my Data Structures and Problem Solving using Java
I am making an application with Java Swing and i have a problem. I
I'm having a small problem in Java. I have an interface called Modifiable. Objects
with my RCP program I have the problem that I want to have more
I have a problem with a keystore in pkcs12 format, which contains a private
I have a Java program that runs on Linux and telnets into a remote

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.