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 main;
- /**
- *
- * @author markjasongalang
- */
- import java.io.*;
- public class Main {
- public static void main(String[] args) throws IOException {
- FileReader file_reader_object = new FileReader("/Users/markjasongalang/Desktop/JAVA-CP/Main/src/main/test.txt");
- int file_iterator = 0;
- String data = "";
- while ((file_iterator = file_reader_object.read()) != -1) {
- if ((char) file_iterator == ' ') {
- data += "_";
- } else {
- data += ((char) file_iterator);
- }
- }
- file_reader_object.close();
- try {
- FileWriter file_writer_object = new FileWriter("/Users/markjasongalang/Desktop/JAVA-CP/Main/src/main/test.txt");
- file_writer_object.write(data);
- file_writer_object.close();
- } catch (Exception e) {
- System.out.println(e);
- }
- System.out.println("Successfully read and written in text file");
- }
- }
Add Comment
Please, Sign In to add comment