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 2 of 2

Thread: Problem with FileReader

  1. #1
    Member
    Join Date
    Jul 2011
    Posts
    53
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Problem with FileReader

    I have to make a program at which i have to read something from a file using FileReader.
    I write here the fragment of the code which reads an integer from the file :

    try
    		{
    			FileReader fr = new FileReader("C:\\Users\\nikipiulitza\\Desktop\\matrice.txt");
    			System.out.println(fr.read());
    			fr.close();
    		}
    		catch(Exception e )
    		{
    			System.out.println(e);
    		}

    In the matrice.txt file i have only written
    2
    And it reads 50 instead of 2....why ? Do i have to make another kind of files if i want to read integers from a file as they are written there ? .txt is not good ?


  2. #2
    Junior Member
    Join Date
    Dec 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem with FileReader

    50 is the ASCII code of the character '2'

    try System.out.println((char)fr.read());

Similar Threads

  1. FileReader argument, compiler problem
    By mwr76 in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: September 10th, 2011, 06:01 PM
  2. Using the fileReader?
    By malconrhymes in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 26th, 2011, 04:47 AM
  3. Scanner/FileReader help
    By JohnTravoltaire in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 28th, 2011, 12:28 AM
  4. FileReader help
    By bibboorton in forum What's Wrong With My Code?
    Replies: 6
    Last Post: September 5th, 2010, 07:29 AM
  5. FileReader need assistance
    By tazjaime in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: November 8th, 2009, 01:12 AM