Results 1 to 4 of 4

Thread: [RESOLVED] FileReader problem

  1. #1

    Thread Starter
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Resolved [RESOLVED] FileReader problem

    Hello! First time posting here... usually on VB However, i have some problems with FileReader. This is what i've came up with (fileName is correct btw):

    Code:
    String fileName="test.txt";
    int sign;
    
        FileReader myStream=new FileReader(fileName);
    
            while((sign=myStream.read())!=-1){
                System.out.print(sign);
            }
    
        myStream.Close();
    First, it returned 49... now... it's returning 49+some numbers. I know it's something easy, but just can't figure it out. Where am i going wrong?

  2. #2

    Thread Starter
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: FileReader problem

    Ok. I've figured out, that if i use FileWriter in combination with FileReader, it perfectly "copies" the file. I've created a new FileWriter and added this code:

    Code:
    myStream2.write(sign);
    Works in flying colors But why this sign cannot be displayed on the screen (by me of course) ; or more important, how can it be displayed on the screen? I've tried to "cast":

    Code:
    (String)(sign)
    it says, "uncomparable types"... I'm loosing it over a simple integer!!!! Anyone?

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: FileReader problem

    Code:
            while((sign=myStream.read())!=-1){
                System.out.print((char)sign);
            }
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

Posting Permissions

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



Click Here to Expand Forum to Full Width