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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:43:43+00:00 2026-05-29T19:43:43+00:00

I have a strange problem: I have a CSV file that I read correctly

  • 0

I have a strange problem: I have a CSV file that I read correctly with Notepad and MS Excel 2010.

I tried reading the rows of this file with this code:

BufferedReader source = new BufferedReader(new FileReader(fileName));
String currentRow = null;
while (null != (currentRow=source.readLine())){
    System.outprintln(currentRow)
}           

When the program runs, I read just the binary characters and the length of the row is different from the reality (I expect 2000 chars for line and I found 55 chars or 1 char).

I work in Eclipse: If I open this CSV file as text editor I read strange chars, when I open it as system editor I read the correct value inside MS Excel.

The type of this file is file with comma separated value of Microsoft Excel: does this file have some binary chars?

I tried to use Apache POI (reading the file in CSV and in XLS) with this code:

public void displayFromExcel (String xlsPath){
    POIFSFileSystem fileSystem = null;
    try{
        fileSystem = new POIFSFileSystem (new FileInputStream (xlsPath));
        HSSFWorkbook workBook = new HSSFWorkbook (fileSystem);
        HSSFSheet sheet = workBook.getSheetAt (0);
        Iterator<Row> rows = sheet.rowIterator();

        while (rows.hasNext ()){
            HSSFRow row = (HSSFRow) rows.next ();
            System.out.println ("Row No.: " + row.getRowNum ());
            Iterator<Cell> cells = row.cellIterator();
            while (cells.hasNext ()){
                HSSFCell cell = (HSSFCell) cells.next ();

                System.out.println ("Cell No.: " + cell.getCellNum ());

                switch (cell.getCellType ()){
                    case HSSFCell.CELL_TYPE_NUMERIC :
                        System.out.println ("Numeric value: " + cell.getNumericCellValue ());
                        break;
                    case HSSFCell.CELL_TYPE_STRING :
                        HSSFRichTextString richTextString = cell.getRichStringCellValue ();
                        System.out.println ("String value: " + richTextString.getString ());
                        break;
                    default :
                        System.out.println ("Type not supported.");
                        break;
                }
            }
        }
    } catch (IOException e) {
        e.printStackTrace ();
    }
}

It isn’t working, I receive this message to the console:

java.io.IOException: Invalid header signature; read 0x003000310030FEFF, expected 0xE11AB1A1E011CFD0
    at org.apache.poi.poifs.storage.HeaderBlockReader.<init>(HeaderBlockReader.java:125)
    at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:153)

When it runs this instruction:

POIFSFileSystem fileSystem = new POIFSFileSystem (new FileInputStream (xlsPath));

I tried to use the library datafile and the Java I/O (DataInputstream, etc.), but without success.

Any idea for the solution?

  • 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-29T19:43:45+00:00Added an answer on May 29, 2026 at 7:43 pm

    You need to read this file with something more complicated than FileReader. Check out How to reliably guess encoding. Then either find something that will read the file as encoded or write something that will filter out the junk. I have found that if you treat a file as straight ASCII and throw out everything that’s not a valid ASCII character, it will read a straight Unicode file (as well as a straight ASCII file) quite nicely. If it’s UTF-8 with Egyptian Hieroglyphics (and you want those Hieroglyphics) this doesn’t work so well.

    So first try to get “them” to give you a better file. When that doesn’t work, do some research in the java.io Javadoc and then do some programming.

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

Sidebar

Related Questions

I have a strange problem, in my settings file everything is enabled that needs
I have a strange problem. I read text from a text file replace all
I have a strange problem with mod_rewrite, the rules that are relevant here are:
I have a strange problem that is only happening in a single location. I
I have a strange problem that I could not solve. When I try to
I have a strange problem in Visual Studio 2010 (C#) using the Report Viewer
I have a strange problem in my project. I have a class that inherits
I have a strange problem when deleteting records using linq, my suspicion is that
I have strange problem... My file strings.xml contains: <?xml version=1.0 encoding=utf-8?> <resources> <string name=building_name>My
I have a rather strange problem. I have a very simple application that reads

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.