Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package Lab0501;
- import java.io.*;
- /**
- *
- * @author Nan Mihai
- */
- public class Prob3 {
- public static void main(String args[]) throws IOException {
- String nume, numeOut;
- String cale;
- cale = "H:\\Anul II\\Programare orientata pe obiecte\\Java\\Lab1\\JavaApplication1\\src\\Lab0501";
- nume = cale + "\\" + "fisier1.txt";
- numeOut = cale + "\\" + "fisier_out.txt";
- String text = "";
- int c;
- char cr;
- try (FileReader f_in = new FileReader(nume)) {
- while((c = f_in.read()) != -1) {
- cr = (char) c;
- if(Character.isUpperCase(cr)) {
- text += Character.toLowerCase(cr);
- } else {
- text += Character.toUpperCase(cr);
- }
- }
- try (PrintStream raf = new PrintStream(new FileOutputStream(numeOut))) {
- raf.printf("%s\n", text);
- raf.close();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment