Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.io.*;
- import java.util.ArrayList;
- public class Main {
- public static void main(String[] args){
- final String source = "resources\\lines.txt";
- File file = new File(source);
- try {
- BufferedReader reader = new BufferedReader(new FileReader(file));
- FileWriter fw = new FileWriter(file,true);
- PrintWriter writer = new PrintWriter(fw,true);
- ArrayList<String> text = new ArrayList<String>();
- String line = reader.readLine();
- while (line!=null){
- line=line.toUpperCase();
- text.add(line);
- line = reader.readLine();
- }
- reader.close();
- for (int i=0;i<text.size();i++){
- writer.println(text.get(i));
- }
- writer.close();
- } catch (FileNotFoundException e) {
- System.out.println("File not found");
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement