I have one file which contains 7 parameters and their respective values.This file is used for configuring hardware devices.But the problem is ,if i insert any junk values(i.e like hjhkhhdsacd) into the file,still the hardware is able to validate those parameters .So i need proper parsing of those.hence can u suggest me any example how to check those conditions??
…sorry, don’t really understand what you’re asking…? If you want to know how best to parse your file, then telling us what format it uses would be kind of useful! Is it XML, JSON, etc?
Let the file be a.xyz
The contents are as follows,
CommConfig = DPCP
Mode = debug_sim
TargetSpec = LOIP
In the above file CommConfig ,Mode ,TargetSpec are parameters and DPCP,debug_sim, LOIP are resp values. and dfdfdfdf , 23434554 are junk values. So i need a logic which should throw appropriate error msg when it encounters those junk values while parsing the same.
One approach would be:
Read in the whole file as a String
Chop it up into lines using StringArray::addLines
Chop each line into tokens using StringArray::addTokens
Only accept valid tokens
Or just use XML or JSON so you don’t need your own parser!
Thank you Very much . .
The TextFieldParser object allows you to parse and process very large file that are structured as delimited-width columns of text, such as log files or legacy database information. Parsing a text file with TextFieldParser is similar to iterating over a text file, while the parse method to extract fields of text is similar to string manipulation methods used to tokenize delimited strings.