Advertisement
Guest User

Untitled

a guest
Oct 20th, 2015
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.ArrayList;
  3.  
  4. public class _02_AllCapitals {
  5. public static void main(String[] args) {
  6. try (
  7. BufferedReader reader = new BufferedReader(new FileReader(new File("resources/Problem1"))))
  8. {
  9. ArrayList<String> list = new ArrayList<String>();
  10.  
  11. String line = reader.readLine();
  12.  
  13. while (line != null) {
  14.  
  15. list.add(line.toUpperCase());
  16.  
  17. line = reader.readLine();
  18. }
  19. try ( PrintWriter writer = new PrintWriter(new FileWriter(new File("resources/Problem1"),false), false)){
  20.  
  21. for (int i = 0; i < list.size(); i++) {
  22. writer.write(list.get(i));
  23. writer.println();
  24. }
  25. }
  26. }
  27. catch (FileNotFoundException fnf){
  28.  
  29. }
  30. catch (IOException ioex){
  31.  
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement