Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: :mad:[help!]what happened to the '\n'!!

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Angry [solved][help!]what happened to the '\n'!!

    import java.util.Formatter;
    import java.io.File;
    import java.io.FileNotFoundException;

    public class EgWriteToFile1
    {
    public static void main(String[] args)
    throws FileNotFoundException
    {
    Formatter out = new Formatter(new File("out.output"));
    out.format("Hi, %4d and %6.2f \n",12, 5.6343);
    out.format("Write string %s \n","Hello");
    out.close();
    System.out.println("Done");
    }
    }

    ==================================

    Hi, guys.
    I ran the code, then in the generated file. I can only find
    ==================================

    Hi, 12 and 5.63 Write string Hello

    ==================================
    could someone told me what happened to the red parts in the codes?

    Thank you!
    Last edited by Codeguess; January 2nd, 2011 at 09:44 AM.


  2. #2
    Junior Member
    Join Date
    Jan 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: :mad:[help!]what happened to the '\n'!!

    btw, i'm a totally fresh... just start JAVA coding yesterday... :-D

  3. #3
    Member
    Join Date
    Dec 2010
    Posts
    46
    Thanks
    0
    Thanked 10 Times in 10 Posts

    Default Re: :mad:[help!]what happened to the '\n'!!

    I have no problems. What are you using to view your output file?

  4. The Following User Says Thank You to JavaHater For This Useful Post:

    Codeguess (January 2nd, 2011)

  5. #4
    Junior Member
    Join Date
    Jan 2011
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile Re: :mad:[help!]what happened to the '\n'!!

    Quote Originally Posted by JavaHater View Post
    I have no problems. What are you using to view your output file?
    I used notepad... And it should be the reason for this problem.

    Now the question is almost solved, because when i copy the result to somewhere else, then I can see that '\n' works.

    XDD

    Thank you ~

  6. #5
    Junior Member
    Join Date
    Dec 2010
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: :mad:[help!]what happened to the '\n'!!

    Quote Originally Posted by Codeguess View Post
    I used notepad... And it should be the reason for this problem.

    Now the question is almost solved, because when i copy the result to somewhere else, then I can see that '\n' works.

    XDD

    Thank you ~
    Wow mate there is something really really wrong with your computer if you can make notepd to show x.java files.