I am trying to compile below code in JDK 1.6 but getting an error "Not a statement" in the below line
File file = new File("/data/userfiles/data/conf/dataConfig.xml"); Since this code has been compiled in previous version like 1.3 and 1.4 version.
Can you please tell me what exactly wrong in this because presence of dataConfig.xml need not be checked in the compile time, it has to be checked only during execution.
Kindly provide me a solution , i have to provide this by tomorrow
Source Code
try
{
if (loglevel != 0)
// writelog("Retrieving configuration");
File file = new File("/data/userfiles/data/conf/dataConfig.xml");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(file);
doc.getDocumentElement().normalize();
NodeList nodeLst = doc.getElementsByTagName("Configuration");
String servername;
Node fstNode = nodeLst.item(0);
Element fstElmnt = (Element)fstNode;
NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("Server");
Element fstNmElmnt = (Element)fstNmElmntLst.item(0);
NodeList fstNm = fstNmElmnt.getChildNodes();
servername = ((Node)fstNm.item(0)).getNodeValue();
Element sndElmnt = (Element)fstNode;
NodeList sndNmElmntLst = sndElmnt.getElementsByTagName("Log");
Element sndNmElmnt = (Element)sndNmElmntLst.item(0);
NodeList sndNm = sndNmElmnt.getChildNodes();
String nodeval;
Node mynode = (Node)sndNm.item(0);
nodeval = mynode.getNodeValue().trim();
loglevel = Integer.parseInt(nodeval);
sndElmnt = (Element)fstNode;
sndNmElmntLst = sndElmnt.getElementsByTagName("LogPath");
sndNmElmnt = (Element)sndNmElmntLst.item(0);
sndNm = sndNmElmnt.getChildNodes();
mynode = (Node)sndNm.item(0);
logpath = mynode.getNodeValue().trim();
if (loglevel != 0)
writelog("Log Path: " + logpath);
if (loglevel != 0)
writelog("Server : " + ((Node)fstNm.item(0)).getNodeValue());
return servername;
}
catch (Exception e)
{
writelog("Error in Get Server IP:" + e.toString());
return ("ERROR");
}