mihainan

Problema 3 - Lab05

Nov 5th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package Lab0501;
  7.  
  8. import java.io.*;
  9.  
  10. /**
  11. *
  12. * @author Nan Mihai
  13. */
  14. public class Prob3 {
  15. public static void main(String args[]) throws IOException {
  16. String nume, numeOut;
  17. String cale;
  18. cale = "H:\\Anul II\\Programare orientata pe obiecte\\Java\\Lab1\\JavaApplication1\\src\\Lab0501";
  19. nume = cale + "\\" + "fisier1.txt";
  20. numeOut = cale + "\\" + "fisier_out.txt";
  21. String text = "";
  22. int c;
  23. char cr;
  24. try (FileReader f_in = new FileReader(nume)) {
  25. while((c = f_in.read()) != -1) {
  26. cr = (char) c;
  27. if(Character.isUpperCase(cr)) {
  28. text += Character.toLowerCase(cr);
  29. } else {
  30. text += Character.toUpperCase(cr);
  31. }
  32. }
  33. try (PrintStream raf = new PrintStream(new FileOutputStream(numeOut))) {
  34. raf.printf("%s\n", text);
  35. raf.close();
  36. }
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment