Why does the eclipse IDE give me terminated error when I try to write a file?

import java.io.*;

public class FileWriterDemo {

/**
 * @param args
 */
public static void main(String[] args) throws IOException {
    // TODO Auto-generated method stub

    String source = "Now is the time for all good men\n" +
                    " to come to aid of their country\n" +
                    " and pay their due taxes";

    char buffer[] = new char[source.length()];
    source.getChars(0, source.length(), buffer, 0);

    FileWriter f0 = new FileWriter("file1.txt");
    FileWriter f1 = new FileWriter("file2.txt");
    FileWriter f2 = new FileWriter("file3.txt");

    try{
        for(int i =0; i<buffer.length; i+=2){
            f0.write(buffer[i]);
        }

        f1.write(buffer);
        f2.write(buffer, buffer.length-buffer.length/4, buffer.length/4);

    }catch (IOException e){
        System.out.println("An I/O Error occured.");
    }
}

}

This is the program that I've written. I copied this program exactly from a book, but my IDE (Eclipse) keeps giving me message. This same problem is encountered when I try to use FileOutputStream class object to create a file and write to it.

Here's an image

Answers


It just means the program completed, and in your case probably sucesfully, since it didnt print anything on console.

Just check the contents of file1.txt , file2.txt and file3.txt to see if the program was successful


Need Your Help

Rails and FullCalendar - Query database with different column names

javascript ruby-on-rails fullcalendar

I am currently using Rails 4.0 and FullCalendar. My problem is: some of the fields in my database correspond differently with those of the FullCalendar defaults. For example:

Connect from AppDelegate to ViewController in Core Data application on Xcode 5

ios objective-c xcode core-data appdelegate

I'm now reading this great tutorial on which an author explains how to connect view controller to app delegate using .xib file (on section 11) in order to use Core Data in different view controllers.