Skip to content

Instantly share code, notes, and snippets.

@AIRAT1
Created September 29, 2014 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AIRAT1/920eaa6ac255c5e8cc70 to your computer and use it in GitHub Desktop.
Save AIRAT1/920eaa6ac255c5e8cc70 to your computer and use it in GitHub Desktop.
com.javarush.test.level19.lesson05.task04
package com.javarush.test.level19.lesson05.task04;
/* Замена знаков
Считать с консоли 2 имени файла.
Первый Файл содержит текст.
Заменить все точки "." на знак "!", вывести во второй файл.
Закрыть потоки ввода-вывода.
*/
import java.io.*;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws IOException{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Scanner scanner = new Scanner(new FileReader(reader.readLine()));
FileWriter writer = new FileWriter(reader.readLine());
String s = "";
while (scanner.hasNext()) {
s = scanner.next();
String[] array = s.split(" ");
for (String x : array) {
x = x.replace(".", "!");
writer.write(x + " ");
}
}
reader.close();
scanner.close();
writer.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment