Simple File Reading problem

S

Stuart P

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);
}

}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top