473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
Jul 17 '05 #1
1 4294
I suggest you take a closer look yourself...

Silvio Bierman

"Alan Fried" <al**@bellatlantic.net> wrote in message
news:39********************************@4ax.com...
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

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: jrlen balane | last post by:
basically what the code does is transmit data to a hardware and then receive data that the hardware will transmit. import serial import string import time from struct import * ser =...
3
by: Vanchau Nguyen | last post by:
Hi all, Hoping someone can help us with this strange Innodb problem. At about 5:15 AM 2/2/04 (this morning), our slave server stopped accepting connections. The machine was pingable, but you...
2
by: Reshma Prabhu | last post by:
hello, I am trying to do an xsl tranformation from an XML file into another xml file. I want the output file to be in MemoryStream so that my dataset can direclty read xml using...
1
by: Ryan Ternier | last post by:
I'm writing a file out using StreamWriter. What i'm outputting is a 6,398 lines of stupid Jscript arrays. Yes the system needs to be very very dynamic, and they don't want a page reload. The...
6
by: sandy | last post by:
I think I just need a pair of eyes here... I can't see what I am doing wrong. I am creating a new Class for an assignment, Class File. I have a header and a cpp file. When I try to write the...
4
by: canteyn | last post by:
Ok here is my problem. I am coding a program that uses 3 different functions, and the end result is that the program reads in (x,y) points from a file, and then outputs those points to another file,...
5
blazedaces
by: blazedaces | last post by:
Ok, so you know my problem, java is running out of memory reading with SAX, the event-based xml parser intended more-so than DOM for extremely large files. I'll try to explain what I've been doing...
3
by: John Carlyle-Clarke | last post by:
Hi. I'm new to Python and trying to use it to solve a specific problem. I have an XML file in which I need to locate a specific text node and replace the contents with some other text. The...
0
by: iprogrammer | last post by:
i have a problem when i try to run my windows service ..which is "Error 1053: The service did not respond to the start or control request in a timely fashion" >after this i cannot anything with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.