Closed Thread
Results 1 to 6 of 6

Thread: Write To File - Should Work??

  1. #1
    UnknownFear's Avatar
    UnknownFear is offline Learning Programmer
    Join Date
    Oct 2009
    Location
    Toronto, Ontario
    Posts
    47
    Blog Entries
    1
    Rep Power
    0

    Question Write To File - Should Work??

    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
    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();
        }
    }
    And this is the WriteFiles class:

    WriteFiles.java
    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();
        }
    }
    I don't understand why it won't work. I followed the tutorial EXACTLY but it won't go. I get this error:

    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?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    UnknownFear's Avatar
    UnknownFear is offline Learning Programmer
    Join Date
    Oct 2009
    Location
    Toronto, Ontario
    Posts
    47
    Blog Entries
    1
    Rep Power
    0

    Re: Write To File - Should Work??

    Does anyone have any idea of how to make this program work? I really would like it to work.

  4. #3
    bobdark's Avatar
    bobdark is offline Programmer
    Join Date
    Jan 2010
    Location
    Haifa, Israel
    Posts
    164
    Rep Power
    9

    Re: Write To File - Should Work??

    It worked for me and I changed nothing in your code. What IDE do you use? I used eclipse.

  5. #4
    UnknownFear's Avatar
    UnknownFear is offline Learning Programmer
    Join Date
    Oct 2009
    Location
    Toronto, Ontario
    Posts
    47
    Blog Entries
    1
    Rep Power
    0

    Re: Write To File - Should Work??

    Quote Originally Posted by bobdark View Post
    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.

  6. #5
    bobdark's Avatar
    bobdark is offline Programmer
    Join Date
    Jan 2010
    Location
    Haifa, Israel
    Posts
    164
    Rep Power
    9

    Re: Write To File - Should Work??

    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.

  7. #6
    UnknownFear's Avatar
    UnknownFear is offline Learning Programmer
    Join Date
    Oct 2009
    Location
    Toronto, Ontario
    Posts
    47
    Blog Entries
    1
    Rep Power
    0

    Re: Write To File - Should Work??

    Quote Originally Posted by bobdark View Post
    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.
    I'll just scrap it than. Thanks for the help though.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [C#] Write text to the beginning of a file
    By PsychoCoder in forum Classes and Code Snippets
    Replies: 0
    Last Post: 08-26-2010, 04:21 PM
  2. [CharnyCoding - C#/XML] Write a XML file
    By Charny in forum Video Tutorials
    Replies: 0
    Last Post: 07-29-2010, 12:42 PM
  3. How To Write To a Text File
    By Hunter100 in forum C and C++
    Replies: 3
    Last Post: 03-25-2010, 01:40 AM
  4. Doesn't write into the file
    By G33k in forum Pascal and Delphi
    Replies: 2
    Last Post: 11-26-2009, 03:45 AM
  5. Read / write file bit by bit
    By tomitzel in forum Java Help
    Replies: 0
    Last Post: 11-03-2009, 12:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts