Question: I want to write an `ArrayList<String>` into a text file. 

The `ArrayList` is created with the code:

```
ArrayList arr = new ArrayList();

StringTokenizer st = new StringTokenizer(
    line, ":Mode set - Out of Service In Service");

while(st.hasMoreTokens()){
    arr.add(st.nextToken());    
}

```

Answer: 
You can do that with a single line of code nowadays.
Create the arrayList and the Path object representing the file where you want to write into:

```
Path out = Paths.get("output.txt");
List<String> arrayList = new ArrayList<> ( Arrays.asList ( "a" , "b" , "c" ) );

```

Create the actual file, and fill it with the text in the ArrayList: 

```
Files.write(out,arrayList,Charset.defaultCharset());

```
I think you can also use BufferedWriter :

```
BufferedWriter writer = new BufferedWriter(new FileWriter(new File("note.txt")));

String stuffToWrite = info;

writer.write(stuffToWrite);

writer.close();

```

and before that remember too add

```
import java.io.BufferedWriter;

```