I have class with main:
public class Main {
// args[0] - is path to file with first and last words
// args[1] - is path to file with dictionary 
public static void main(String[] args) {
    try {
        List<String> firstLastWords = FileParser.getWords(args[0]);
            System.out.println(firstLastWords);
        System.out.println(firstLastWords.get(0).length());
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}
}
and I have FileParser:
public class FileParser {
    public FileParser() {
    }
    final static Charset ENCODING = StandardCharsets.UTF_8;
    public static List<String> getWords(String filePath) throws IOException {
        List<String> list = new ArrayList<String>();
        Path path = Paths.get(filePath);
        try (BufferedReader reader = Files.newBufferedReader(path, ENCODING)) {
            String line = null;
            while ((line = reader.readLine()) != null) {
                String line1 = line.replaceAll("\\s+","");
                if (!line1.equals("") && !line1.equals(" ") ){
                    list.add(line1);
                }
            }
            reader.close();
        }
        return list;
    }   
}
args[0] is the path to txt file with just 2 words. So if file contains:
тор
кит
programm returns:
[тор, кит]
4
If file contains:
т
тор
кит
programm returns:
[т, тор, кит]
2
even if file contains:
    //jump to next line
    тор
    кит
programm returns:
[, тор, кит]
1
where digit - is length of the first string in the list.
So the question is why it counts one more symbol?
firstLastWords.get(1).length()– HasaDev Apr 28 '15 at 01:30it will give right result.