Java, basic question, filewriter

SnoopCat

Senior member
Jan 19, 2001
926
0
0
can someone please post an example of outputing a string that holds "steve" into a file which will be created by java and be called "myName.txt"
 

Argo

Lifer
Apr 8, 2000
10,045
0
0
Is this just a fancy way of telling us that your name is Steve? Well, I'm Joseph, nice to meet you. :)
 

StageLeft

No Lifer
Sep 29, 2000
70,150
5
0
Open file input as "filename";
insert "joseph !!:
compile



That might work :p
 

import java.io.*;

public class WriteName
{
public static void main(String[] args)
throws IOException
{
FileWriter out = new FileWriter("myname.txt");
PrintWriter pr = new PrintWriter(out);
pr.print("Steve");
pr.flush();
pr.close();
}
}

Glad to do your homework for you.
 

huanaku

Golden Member
Jan 20, 2001
1,208
0
0
dwell, thanks :) not my homework, I'm learning Java over the summer, and I was wondering how to write to txt files.