Hello all. I am trying to make a program that will write text to a file. I am also following a tutorial to understand it better and it's going along smoothly
Here is the File class:
Files.java
And this is the WriteFiles class:Code:// Files // Main // Fri Mar 6/10 // Daniel Millier class Files{ public static void main(String[] args){ WriteFiles program = new WriteFiles(); program.openFile(); program.addInfo(); program.closeFile(); } }
WriteFiles.java
I don't understand why it won't work. I followed the tutorial EXACTLY but it won't go. I get this error:Code:// WriteFiles // Write info to text files // Sat Mar 6/10 // Daniel Millier import java.util.*; import java.io.*; import java.lang.*; public class WriteFiles{ private Formatter x; public void openFile(){ try{ x = new Formatter("test.txt"); } catch(Exception e){ System.out.println("Error!"); } } public void addInfo(){ x.format("%s%s%s", "Daniel ", "19 ", "Millier"); } public void closeFile(){ x.close(); } }
x.format("%s%s%s", "Daniel ", "19 ", "Millier");
*** Semenatic Error: No applicable overlaod for a method with signature "format(java.lang.String, java.lang.String, java.lang.String, java.lang.String)" was found in type "java.util.formatter". Perhaps you wanted the overloaded version "java.util.Formatter format(java.util.Locate $1, java.util.Locate $2, java.lang.Object...
It should work cause I did it before. Any help?
Does anyone have any idea of how to make this program work? I really would like it to work.
It worked for me and I changed nothing in your code. What IDE do you use? I used eclipse.
I am using the compiler called "Jikes. Please note that I am not actually programming this on my computer, I am writing it on my iPhone 3GS as it is jailbroken so I can install compilers and the such. It should still work regardless though wouldn't you think? I know Jikes does not support the Scanner package which really sucks as it is much simpler to get input that using BufferedReader.
My word is that the problem is with the compiler because its a compilation error, the parameters suit the API format properly and it works with eclipse, which I had no weird problems with so far.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks