Created
September 29, 2014 16:22
-
-
Save AIRAT1/920eaa6ac255c5e8cc70 to your computer and use it in GitHub Desktop.
com.javarush.test.level19.lesson05.task04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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