function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sslatersslater 

Read file with apex/vf

Does anyone know a way to read a file via apex/vf? I'm looking for a way to prompt the user for a file, then turn that into a stream reader, just like you would get back from an HTTP or XML request. Then my own parser can parse the file and do fun things with it.

The dataloader doesn't help because I'm not inserting records. I don't mind creating a document, reading it, then deleting it, but didn't see where you can read from a document with apex.

Does anyone have a good way to do this?

Thanks!
JimRaeJimRae
Look at the VF inputfile tag.  It prompts the user to browse their file system for a file, and loads it to a document object.
you should be able to read the body of the document into something like the XMLStreamreader to do your processing.