dcsimg
Stumped on IO
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, June 18, 2002 02:03 PM

I have a class in one of my project that I want to use to create files and write to files. But it won't get passed the compiler. Every time I build it I get the following message: Suggestions.java:95: unreported exception java.io.IOException; must be caught or declared to be thrown WriteThis.WriteIt (saveThis); Suggestions is the class I used to call the method WriteIt in my class WriteThis, and pass an array to be written to a file. The code for my WriteThis class looks something like this import java.io.*; public class WriteThis { public static void WriteIt (String []WhatToWrite) throws IOException { try { String fileName = what   More>>

I have a class in one of my project that I want to use to create files and write to files. But it won't get passed the compiler. Every time I build it I get the following message:

			
Suggestions.java:95: unreported exception java.io.IOException; must be caught or declared to be thrown
WriteThis.WriteIt (saveThis);


Suggestions is the class I used to call the method WriteIt in my class WriteThis, and pass an array to be written to a file. The code for my WriteThis class looks something like this

			
import java.io.*;

public class WriteThis
{
public static void WriteIt (String []WhatToWrite) throws IOException
{
try
{
String fileName = whatToWrite [0];
String writeOnLine;
FileWriter fw = new FileWriter (fileName);
BufferedWriter bw = new BufferedWriter (fw);
PrintWriter outFile = new PrintWriter (bw);

for (int line = 1; line <= whatToWrite.length; line++)
{
for (int i = 1; i < whatToWrite.length; i++)
{
writeOnLine = whatToWrite [i];
outFile.print (writeOnLine);
}
outFile.println ();
}

outFile.close ();
}

catch (IOException e)
{
String error = "There was an error";
}
}
}


I've tried throwing the exception, I've tried catching it but I always get the same error when I compile it. Is there something I'm missing? Any help is welcomed help, thanks

-Conor.    <<Less

Got it

Posted By:   Anonymous  
Posted On:   Wednesday, June 19, 2002 06:36 AM

Never mind I got it to work.
About | Sitemap | Contact