| dijeshharidas@gmail.com 2006-04-07, 7:27 am |
| THis is a java code for getting the xml data from an XMl file...Please
help me to make a Junit test case to test this piece of code.
public static StringBuffer getXMLData(String fileName) throws
NBCException {
//Creating the string buffer to get the data from the xml
StringBuffer xmlDataStream = new StringBuffer();
try {
//Creating the FileReader object to read the contents of the
xml file
FileReader frForXML = new FileReader(fileName)
;
//char array to hold the data of the xml file
char xmlData[] = new char[1000];
//integer variable to hold the character data of the xml
file
int v = 0;
//Read till end of file
while ((v = frForXML.read(xmlData)) != -1) {
//putting the xml data into the string buffer
xmlDataStream.append(xmlData, 0, v);
}
//closing the FileReader object
frForXML.close();
}
catch (Exception expXMLNotFound) {
throw new NBCException("Could not find the xml file at the specified
location : " + fileName);
}
return xmlDataStream;
}
|