1
File folderPathFile = new File("C:\\Users\\ali\\Desktop\\folderPath.txt");


    BufferedReader reader = new BufferedReader(new FileReader(folderPathFile));
    String line = reader.readLine();
    while(line != null){
        foldersPath.add(line);
        line = reader.readLine();
    }
    reader.close();


    String lineDup = line.toString();
        String[] LineSplits = lineDup.split(",");


        String[] array = LineSplits[1].trim().split(" ");
        for(int i =0; i<array.length;i++) {
            int fr = Integer.parseInt(array[i]);
            System.out.println(fr);//its printing
        }

        int fr1 = Integer.parseInt(LineSplits[0]);
        System.out.println(fr1);
}                                            

My Problem is when i run this code i've java.lang.Exception: java.lang.NumberFormatException: For input string: "900"

INPUT i'm Giving i.e myfile data is 900, 200 300 400 500 600

Why for 900 only i'm getting such error ?

user4834352
  • 35
  • 1
  • 4

2 Answers2

2

Check for the lineSplit[0] length if it's 4 then there is an invisible character i.e ZERO WIDTH NO-BREAK SPACE . It's hard to detect as it's invisible and trimming won't delete that character. If so you need to get rid of that character

EDIT: As you are Saying it's length is 4. try this LineSplits[0].replace(u'\ufeff', '') or You can write that number yourself instead of copying it from somewhere

You can check the long discussion about this character here on this SO Question though it's regarding HTML but makes sense how this character comes and all

Community
  • 1
  • 1
Ankur Anand
  • 3,873
  • 2
  • 23
  • 44
0

If you are newbie to MapReduce programming and just learning from sample input file that you have copy pasted from the web then just create input file manually as during copy paste some UTF characters also get pasted.

I solved the issue by manually creating sample file.

Prashant
  • 601
  • 5
  • 6