You need to sign in to do that
Don't have an account?
Help required in reading a text file
Hi,
I am writing an apex class where I have to refer certain pre-known values (I will run validation against these pre-known values). Initially I had thought to use a custom object with just one field and store as many object values as I can. Then I was planning to get those values using simple query against custom object.
But my customer insists that I should not be using a custom object. Rather, I should be using a static resource (some sort of text file with pre-known values) and I should read that text file using apex code. I have not done this thing before.
I know how to upload a text file as static resource but I have absolutely no idea of how would I read that text file in my apex code.
I have to read that file, get all the values that have been mentioned in text file (each individual entry in new line) in a LIST.
I can take it from there.
Just help in 'how to read static resource of text file' would be appreciated.
Thanks,
Anuj
Actually, a CustomSetting would be even better than a custom object. But since the client is always right, here's the solution:
Of course, if it is an XML file, you could instead use XML streams to read the file.
Thanks a ton.
That was very quick response and worked like a charm.
am sure, newbie in salesforce like me will get enormous help here.
I welcome myself to this community :-)
Thanks,
Anuj
We are a very mature community with many knowledgeable and helpful members. Welcome to the community, and I do hope that you learn a lot about the force.com platform and use it to your fullest advantage.
Anuj,
Please mark above solution as accepted , and help to community.
Thanks,
Bala
Hi,
I have a similar requirement but little more complex. I have a static resource and within that I have number of xml files. I want to read a specific xml file from the static resource into an xmlDom object in apex. How can I do that?