Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > Problem With Outputs of Simple Program Using File Writer
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 25th November 16:58
alan fried
External User
 
Posts: 1
Default 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
  Reply With Quote


  sponsored links


2 25th November 16:58
silvio bierman
External User
 
Posts: 1
Default Problem With Outputs of Simple Program Using File Writer


I suggest you take a closer look yourself...

Silvio Bierman
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666