Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. public class Solution {
  4. public static void main(String[] args) throws IOException {
  5.  
  6. boolean flag = true;
  7.  
  8. try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
  9.  
  10. String sourceFileName = reader.readLine();
  11. String destinationFileName = reader.readLine();
  12.  
  13. while (flag) {
  14. try (FileOutputStream fileOutputStream = new FileOutputStream(destinationFileName);
  15. FileInputStream fileInputStream = new FileInputStream(sourceFileName)) {
  16.  
  17. int value;
  18. char content;
  19.  
  20. while ((value = fileInputStream.read()) != -1) {
  21.  
  22. content = (char) value;
  23. fileOutputStream.write(content);
  24. }
  25.  
  26. flag = false;
  27. }
  28. catch (FileNotFoundException e) {
  29. System.out.println("Файл не существует.");
  30. sourceFileName = reader.readLine();
  31. }
  32. }
  33. }
  34. catch (IOException e) {
  35. e.printStackTrace();
  36. }
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement