1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

read matrix input file and store it in matrix

Discussion in 'Java' started by shima, Apr 16, 2009.

  1. shima

    shima New Member

    Joined:
    Apr 16, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hi,

    i having problem in reading input value in matrix form and store it in matrix.

    below is a sample of my input file (ref.txt)

    A1 A2 A3 A4 A5 A6 A7 A8
    q1 1 0 0 1 0 1 1 0
    q2 0 1 1 0 1 0 0 0
    q3 0 0 0 1 0 0 1 1
    q4 0 1 0 0 0 1 0 1
    q5 1 0 0 0 0 0 1 0
    q6 0 0 1 0 1 0 0 1

    how should i read this kind of input???
     
  2. asadullah.ansari

    asadullah.ansari TechCake

    Joined:
    Jan 9, 2008
    Messages:
    356
    Likes Received:
    14
    Trophy Points:
    0
    Occupation:
    Developer
    Location:
    NOIDA
    take two loop one is for row means end of file and other is for column means end of line...
    and skip white space(according to your text file)...
    Example:
    Code:
    for i=0 to EOF
       for j=0 to EOL
             Skip according to your file which character  you have to skip menas like white space
             Mat[i][j]= read contents by file Pointer
     

Share This Page