Question: in Java, I can't figure out how to write to a text file and also read it back in the console. The problem is that

in Java, I can't figure out how to write to a text file and also read it back in the console. The problem is that when I write it to the text file the text doesn't look write and has strange characters.

in Java, I can't figure out how to write to a text

this is some of my code below minus any code referring to reading or writing ... I will want to add more objects from a different class later but I'm just confused here.

package homework6;

import java.io.*;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.ObjectInputStream;

import java.io.ObjectOutputStream;

public class Maindriver {

public Maindriver() {

// TODO Auto-generated constructor stub

}

public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {

Friend friend1 = new Friend("Ben", "Allen", "ballen@yahoo.com", "918-489-4231", "Tulsa");

Friend friend2 = new Friend("Armand", "Etame", "aetame@aol.com", "918-493-1001", "Tulsa");

Friend friend3 = new Friend("Adam", "Faurie", "afaurie@cox.net", "918-299-1218", "Tulsa");

Friend friend4 = new Friend("Kevin", "O'keefe", "kokeefe@)sbcglobal.net", "918-564-1284", "Tulsa");

String fileName ="Friend.txt";

}}

Friend - Notepad File Edit Format View Help firstNameq lastNameqL phoneNumberq .. xpt Tulsat Dba llen@yahoo.comt DBent lAllent 4918-489-4231sq q n, jt Daetame@aol.comt Darma ndt DEtamet 918-493-1001 sq ~ q ~ 0t lafaurie@cox . nett Dadamt CFauriet 4918-299-1218sq ~ q ~ It 0kokeefe@)sbcglobal, nett OKevint JO'keefet 4918-564-1284

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!