What's Here?
- Members: 300,315
- Replies: 825,542
- Topics: 137,367
- Snippets: 4,417
- Tutorials: 1,147
- Total Online: 2,058
- Members: 106
- Guests: 1,952
|
The easiest way to write to a file, without any weird characters showing.
|
Submitted By: tygerberg
|
|
Rating:
 
|
|
Views: 22,933 |
Language: Java
|
|
Last Modified: October 2, 2007 |
Snippet
import java.io.*;
public class Firstfile
{
{
/*"FileWriter first = new FileWriter(new File("first.txt"));"
FileWriter first = new FileWriter indicates that a new FileWriter is in use.
(new File("first.txt")); creates the file called first, in quotations.*/
int s, x, a;
s = 10;
x = 10;
a = s + x;
//Small calculation to show what can be done.
//It's very simple, using only xyz.write("");
first.write("First file in java"); //The following lines writes
first.write("s + x = "+ a); //to the file.
first.close(); //Closes the file
} // main method
} // Firstfile class
Copy & Paste
|
|
|
|