Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Urgent: Output and loop
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
IntelMaster




PostPosted: Sun Jun 06, 2010 10:29 am   Post subject: Urgent: Output and loop

[code
try {
String file=jTextField12.getText();
DataOutput f=new DataOutputStream(new
FileOutputStream(file+".txt"));
f.writeBytes("Answers");
for (int output=0; output<count1; output++)
f.writeBytes(count1+"="+answer1[count1]);








} catch (Exception e)
{ String msg=e.toString ();
} // TODO add your handling code here:
}
]

For some reason this program isn't working
Sponsor
Sponsor
Sponsor
sponsor
TheGuardian001




PostPosted: Sun Jun 06, 2010 7:01 pm   Post subject: Re: Urgent: Output and loop

Can you be more specific? What exactly do you mean when you say "For some reason it doesn't work"?

Does the program give an error message? Is it not outputting anything at all, or is it just outputting wrong?

It would probably help to see what the problem is if you gave a full program, instead of a chunk of code that can't be run on its own.
Unnamed.t




PostPosted: Sun Jun 06, 2010 7:44 pm   Post subject: Re: Urgent: Output and loop

TheGuardian001 wrote:
Can you be more specific? What exactly do you mean when you say "For some reason it doesn't work"?


Yup, I agree. For all we know your program could just have some stupid mistake like the method not throwing an IOException or forgeting to import a class or... (u know wut I mean)

It could help a lot if you can copy and paste your code from top to bottom of the whole file.
Zren




PostPosted: Sun Jun 06, 2010 8:35 pm   Post subject: RE:Urgent: Output and loop

You have to close IO streams before it actually writes anything to file in java.
DemonWasp




PostPosted: Mon Jun 07, 2010 12:21 am   Post subject: RE:Urgent: Output and loop

Alternately, you can call .flush() on them to force them to write - this is actually done as part of the close() operation.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: