Problem With Outputs of Simple Program Using File Writer
The following program is supposed to write the
lower case letters of the alphabet to a text
file. Here is the code:
import java.io.*;
class createFile4 {
public static void main (String[] args) throws IOException {
FileWriter outputFile = new FileWriter ("Numbers.txt");
int buffer = 26;
char [] numbers = new char[buffer];
for(char c = 'a',i = 0; c<='z'&& i<=26; c++, i++){
numbers[i] =c;
outputFile.write(buffer);
}
outputFile.flush();
outputFile.close();
}
Here is the output I get to the file:
I also get the same output to a file with this program as well
which is supposed to write the nu,bers 1 to 25.
import java.io.*;
class createFile2 {
public static void main (String[] args) throws IOException {
FileWriter outputFile = new FileWriter ("Letters.txt");
for(int i = 1; i<=25; i++){
outputFile.write(i);
}
outputFile.close();
}
}
Any suggestions?
Thanx in advance
Alan
|