Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void writeToFile(String file, List<String> lines){
- try {
- BufferedWriter bw = null;
- try{
- bw = new BufferedWriter(new FileWriter(file));
- for(int i = 0; i < lines.size(); i++){
- bw.write(lines.get(i));
- bw.newLine();
- }
- } catch (IOException e) {
- // exception writing to file...
- } finally {
- if(bw != null) {
- bw.close();
- }
- }
- } catch(IOException e) {
- // if close throws an exception...
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment