Question: Hello, I want to read a file, file.txt that contains word pairs like this... 

```
mot;word 
oui;yes
utiliser;use
comment;how

```

After reading this file.txt , I want to split this text and put the French words in an ArrayList and the English words in an another ArrayList.

Thanks in advance...

Answer: 
```
public static void main(String[] args) {
    List<String> list = new ArrayList<String>(); 
    List<String> frenchList = new ArrayList<String>();
    List<String> englishList = new ArrayList<String>();
    File file = new File("C:/dico.txt");
    if(file.exists()){
        try { 
            list = Files.readAllLines(file.toPath(),Charset.defaultCharset());
        } catch (IOException ex) {
            ex.printStackTrace();
        }
      if(list.isEmpty())
          return;
    }
    for(String line : list){
        String [] res = line.split(";");
        frenchList.add(res[0]);
        englishList.add(res[1]);
    }
}

```

With this code you have de french word in the list "frenchlist" and the english words in the list "englishlist"
This looks like CSV file. Consider using CSV reader library.

Use [String#split](http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#split%28java.lang.String%29) function from JDK and read file line by line with [Scanner](http://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html#Scanner(java.io.File)):

```
Scanner scanner = new Scanner(file);
while (scanner.hasNextLine()) {
  String line = scanner.nextLine();
  // process the line using String#split function
}

```

In `while` loop add splited data to `ArrayList`.

All information are already on stackoverflow.

* [Read String line by line in Java](https://stackoverflow.com/questions/1096621/how-to-read-a-string-line-per-line)
* [How to split a comma separated String while ignoring escaped commas?](https://stackoverflow.com/questions/820172/how-to-split-a-comma-separated-string-while-ignoring-escaped-commas)
* [Reading File by line instead of word by word](https://stackoverflow.com/questions/20318872/reading-file-by-line-instead-of-word-by-word/20318898#20318898)
* [Read line using Java New I/O](https://stackoverflow.com/questions/8035981/read-line-using-java-new-i-o)
* [CSV API for Java](https://stackoverflow.com/questions/101100/csv-api-for-java)