Simple File Reading problem

Discussion in 'Java' started by Stuart P, Aug 12, 2004.

  1. Stuart P

    Stuart P Guest

    Hi I'm trying to read out matched pairs from a file, problem is that letter
    and value and in different formats throughout the file. I cannot change the
    file's format even though it would be much easier, I have nearly got it all,
    jus one character off. All help would be greatly appreciated
    I need to save it in the format
    textVal = p; text1 = 62110569509148567 etc; and loop through
    textVal = q; text1 = 7450261097869638227 etc

    TIA Stu

    FILE: AlicePublicKey.txt

    Public Verification Key PK = (p,q,g,y)

    p= 621105695091485670313174473006421440376032538718042228

    q=745026109786963822726304673504024492638067284317
    g= 3116052716138815908300608052901829427316684517053696550
    y=
    211678276124452467725502455722761127042560473816357


    MY CODE:
    public void readKeys()
    {
    String file = "AlicePublicKey.txt";
    String text = new String();
    String text1 = new String();
    char textVal;
    String text2 = new String();
    StringTokenizer tokenizer;
    BigInteger kValue;

    try
    {
    FileReader fr = new FileReader(file);
    BufferedReader inFile = new BufferedReader(fr);

    text = inFile.readLine();
    textVal = ' ';
    while(text != null)
    {
    text = inFile.readLine();

    if(text != null)
    {
    for(int i=0;i<text.length();i++)
    {
    if(Character.isDigit(text.charAt(i)))
    {
    if(Character.isLetter(text.charAt(0)))
    {
    textVal = text.charAt(0);
    }
    text1 = text.substring(i,text.length());
    System.out.println(textVal+"\n");
    System.out.println(text1+"\n");
    setValue(textVal, text1);
    break;
    }
    }
    }
    }
    inFile.close();
    }
    catch(Exception e)
    {
    System.out.println("Trouble with reading file: " + e);
    }

    }
     
    Stuart P, Aug 12, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darrel
    Replies:
    3
    Views:
    699
    Kevin Spencer
    Nov 11, 2004
  2. Wael Soliman

    ASP.NET Reading problem (reading .xls)

    Wael Soliman, Jan 3, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    4,823
    =?Utf-8?B?dmluYXk=?=
    Jan 3, 2005
  3. Shane
    Replies:
    7
    Views:
    382
    Shane
    Aug 23, 2004
  4. Replies:
    0
    Views:
    807
  5. Karim Ali

    Reading a file and resuming reading.

    Karim Ali, May 25, 2007, in forum: Python
    Replies:
    2
    Views:
    393
    Hrvoje Niksic
    May 25, 2007
Loading...

Share This Page