Revision 1688 tmp/org.txm.core/src/java/org/txm/scripts/importer/DisplayXmlTags.groovy

DisplayXmlTags.groovy (revision 1688)
76 76
	 */
77 77
	private boolean processxmlFile(File xmlfile)
78 78
	{
79
		def inputData = null;
80
		def factory = null;
79 81
		try
80 82
		{
81 83
			URL url = xmlfile.toURI().toURL();
82
			def inputData = url.openStream();
83
			def factory = XMLInputFactory.newInstance();
84
			inputData = url.openStream();
85
			 factory = XMLInputFactory.newInstance();
84 86
			XMLStreamReader parser = factory.createXMLStreamReader(inputData);
85 87
			for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) 
86 88
			{
......
107 109
						sum += parser.getText().trim().length();
108 110
				}
109 111
			}
110
			
112
			parser.close();
113
			inputData.close();
111 114
		}
112
		catch(Exception e){println("File "+xmlfile+"\n"+e); return false;}
115
		catch(Exception e){
116
			println("File "+xmlfile+"\n"+e);
117
			if (parser != null) parser.close();
118
			if (inputData != null) inputData.close();
119
			return false;
120
		}
121
		
113 122
		return true;
114 123
	}
115 124

  

Also available in: Unified diff