Revision 1688

tmp/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java (revision 1688)
29 29

  
30 30
import java.io.File;
31 31
import java.io.IOException;
32
import java.io.InputStream;
32 33
import java.io.PrintStream;
33 34
import java.lang.reflect.InvocationTargetException;
34 35
import java.net.URL;
......
386 387
			try {
387 388
				URL url = new URL("http://textometrie.ens-lyon.fr/dist/index.html"); //$NON-NLS-1$
388 389
				Log.fine(TXMCoreMessages.bind("Testing if update site is available: {0}...", url)); //$NON-NLS-1$
389
				url.openStream().read();
390
				InputStream data = url.openStream();
391
				data.read();
392
				data.close();
390 393
			} catch(Exception e){
391 394
				Log.warning(TXMCoreMessages.bind("TXM can not fetch updates ({0}).", e));
392 395
				doUpdate = false;
tmp/org.txm.oriflamms.rcp/groovy/org/txm/macro/oriflamms/prepare/CopyXMLFiles.groovy (revision 1688)
34 34
				//println "Resolving $publicID $systemID $baseURI $namespace"
35 35
				File srcFile = new File(xmlFile.getParentFile(), systemID);
36 36
				dtdFiles << srcFile
37
				return srcFile.toURI().toURL().openStream();
37
				return srcFile.toURI().toURL());
38 38
			}
39 39
		});
40 40
	
tmp/org.txm.oriflamms.rcp/src/org/txm/oriflamms/functions/CopyXMLFiles.java (revision 1688)
48 48
		for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {
49 49
			
50 50
		}
51
		
51
		if (parser != null) parser.close();
52
		if (inputData != null) inputData.close();
52 53
		dtdFiles.add(xmlFile);
53 54
		for (File dtd : dtdFiles) {
54 55
			File cpy = new File(outDir, dtd.getName());
tmp/org.txm.utils/src/org/txm/utils/io/IOUtils.java (revision 1688)
221 221
		return lines;
222 222
	}
223 223

  
224
	/**
225
	 * 
226
	 * @param manifest
227
	 * @return an InputStream, dont forget to close it
228
	 * @throws MalformedURLException
229
	 * @throws IOException
230
	 */
224 231
	public static InputStream getInput(File manifest) throws MalformedURLException, IOException {
225 232
		return manifest.toURI().toURL().openStream();
226 233
	}
tmp/org.txm.core/src/java/org/txm/importer/StaxIdentityParser.java (revision 1688)
80 80
		parser = null;
81 81
	}
82 82

  
83
	protected void closeForError() throws XMLStreamException {
84
		parser.close();
83
	protected void closeForError() throws XMLStreamException, IOException {
84
		if (parser !=null) parser.close();
85
		if (inputData != null) inputData.close();
85 86
	}
86 87

  
87 88
	/**
......
188 189
			if (writer != null) writer.close();
189 190
			if (output != null) output.close();
190 191
			parser.close();
192
			inputData.close();
191 193
			return false;
192 194
		}
193 195
		//if (processingXInclude == 0) {
tmp/org.txm.core/src/java/org/txm/importer/scripts/xmltxm/AnnotationInjection.groovy (revision 1688)
156 156
			}
157 157
		}
158 158
		headerparser.close();
159
		anainputData.close();
159 160
	}
160 161

  
161 162
	/**
......
185 186
			}
186 187
		}
187 188
		anaparser.close();
189
		anainputData.close();
188 190
		return links;
189 191
	}
190 192

  
tmp/org.txm.core/src/java/org/txm/importer/scripts/xmltxm/WLX2TXMTEI.groovy (revision 1688)
244 244

  
245 245
				output.close();
246 246
				parser.close();
247
				inputData.close();
247 248
			}
248 249
			catch (XMLStreamException ex) {
249 250
				System.out.println(ex);
tmp/org.txm.core/src/java/org/txm/importer/scripts/xmltxm/InlineCleaner.groovy (revision 1688)
176 176
		}
177 177
		output.close();
178 178
		parser.close();
179
		inputData.close();
179 180
	}
180 181

  
181 182
	/**
tmp/org.txm.core/src/java/org/txm/importer/scripts/xmltxm/AnnotationInjectionFromTTOutput.groovy (revision 1688)
136 136
			}
137 137
		}
138 138
		headerparser.close();
139
		anainputData.close();
139 140
	}
140 141

  
141 142
	/**
......
165 166
			}
166 167
		}
167 168
		anaparser.close();
169
		anainputData.close();
168 170
		return links;
169 171
	}
170 172

  
tmp/org.txm.core/src/java/org/txm/importer/scripts/xmltxm/AnnotationExtraction.groovy (revision 1688)
174 174
					this.respStmt += "\n</respStmt>"
175 175
					System.out.println(this.respStmt);
176 176
					parser.close();
177
					inputData.close()
177 178
					return;
178 179
				} else {
179 180
					if (!solotags.contains(parser.getLocalName()))
......
187 188
				respStmt += txt;
188 189
			}
189 190
		}
191
		parser.close();
192
		inputData.close()
193
		return;
190 194
	}
191 195

  
192 196
	/**
tmp/org.txm.core/src/java/org/txm/scripts/importer/WordCounter.groovy (revision 1688)
167 167
								sid = sid.split("_")[0];
168 168
								break;
169 169
							}
170
						inputData.close();
171
						parser.close();
170
						if (parser != null) parser.close();
171
						if (inputData != null) inputData.close();
172 172
						return sid;
173 173
					}
174 174
			}
175 175
		}
176
		if (parser != null) parser.close();
177
		if (inputData != null) inputData.close();
176 178
    }
177 179
    
178 180
    /**
tmp/org.txm.core/src/java/org/txm/scripts/importer/CopyXMLFiles.groovy (revision 1688)
43 43
		for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {
44 44
			
45 45
		}
46
		parser.close();
47
		inputData.close();
46 48
		
47 49
		dtdFiles << xmlFile
48 50
		for (File dtd : dtdFiles) {
tmp/org.txm.core/src/java/org/txm/scripts/importer/SAttributesListener.groovy (revision 1688)
196 196
				if (TEXT.equals(parser.getLocalName())) start = false;
197 197
			}
198 198
		}
199
		parser.close()
199
		if (parser != null) parser.close();
200
		if (inputData != null) inputData.close();
200 201
		
201 202
		return listener
202 203
	}
tmp/org.txm.core/src/java/org/txm/scripts/importer/XMLTXM2WTC.groovy (revision 1688)
384 384
			}
385 385
			//output.write("</txmcorpus>\n");
386 386
			output.close();
387
			parser.close();
387
			if (parser != null) parser.close();
388
		if (inputData != null) inputData.close();
388 389
		} catch (Exception ex) {
389 390
			println "Error while parsing $url : "+ex
390 391
			ex.printStackTrace();
392
			if (parser != null) parser.close();
393
			if (inputData != null) inputData.close();
391 394
			return false;
392 395
		}
393 396
		return true;
tmp/org.txm.core/src/java/org/txm/scripts/importer/ReadImportParameters.groovy (revision 1688)
44 44
			def inputData = url.openStream();
45 45
			def factory = XMLInputFactory.newInstance();
46 46
			def parser = factory.createXMLStreamReader(inputData);
47
			return read(parser);
47
			boolean ret = read(parser);
48
			if (parser != null) parser.close();
49
			if (inputData != null) inputData.close();
50
			return ret;
48 51
		} catch (XMLStreamException ex) {
49 52
			System.out.println(ex);
50 53
		}catch (IOException ex) {
51 54
			System.out.println("IOException while parsing ");
52 55
		}
56
		
53 57
	}
54 58

  
55 59
	public boolean read(def parser)
tmp/org.txm.core/src/java/org/txm/scripts/importer/StaxParser.groovy (revision 1688)
46 46
	protected void after()
47 47
	{
48 48
		factory = null;
49
		if (parser !=null) parser.close();
49
		if (parser != null) parser.close();
50
		if (inputData != null) inputData.close();
50 51
		parser = null;
51 52
	}
52 53
	
53 54
	protected void closeForError() {
54
		parser.close();
55
		if (parser != null) parser.close();
56
		if (inputData != null) inputData.close();
55 57
	}
56 58

  
57 59
	public boolean process()
......
97 99
			println("Unexpected error while parsing file "+inputurl+" : "+e);
98 100
			println("Location line: "+parser.getLocation().getLineNumber()+" character: "+parser.getLocation().getColumnNumber());
99 101
			org.txm.utils.logger.Log.printStackTrace(e);
100
			parser.close();
102
			if (parser != null) parser.close();
103
		if (inputData != null) inputData.close();
101 104
			return false;
102 105
		}
103 106
		
tmp/org.txm.core/src/java/org/txm/scripts/importer/MileStoneProjection.groovy (revision 1688)
73 73
			}
74 74
		}
75 75
		milestonesLength[milestonesCounter] = mileStoneDistance;
76
		parser.close()
76
		if (parser != null) parser.close();
77
		if (inputData != null) inputData.close();
77 78
		milestonesCounter = 0;
78 79
		//println milestonesLength
79 80
	}
tmp/org.txm.core/src/java/org/txm/scripts/importer/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

  
tmp/org.txm.core/src/java/org/txm/scripts/importer/HTMLIndexer.groovy (revision 1688)
104 104
		String lasttoken;
105 105
		String page;
106 106
		
107
		def inputData = null;
108
		def factory = null;
109
		
107 110
		try
108 111
		{
109 112
			URL url = htmlFile.toURI().toURL();
110 113
			println "process html file "+url;
111
			def inputData = url.openStream();
112
			def factory = XMLInputFactory.newInstance();
114
			inputData = url.openStream();
115
			factory = XMLInputFactory.newInstance();
113 116
			//factory.setXMLResolver resolver
114 117
			//factory.setProperty(factory.IS_VALIDATING, false)
115 118
			factory.setProperty("javax.xml.stream.supportDTD", false);
......
150 153
			}
151 154
			
152 155
		}
153
		catch(Exception e){println("File "+htmlFile+"\n"+e); return false;}
156
		catch(Exception e){println("File "+htmlFile+"\n"+e); 
157
			if (parser != null) parser.close();
158
		if (inputData != null) inputData.close();
159
		return false;}
160
		
161
		if (parser != null) parser.close();
162
		if (inputData != null) inputData.close();
154 163
		return true;
155 164
	}
156 165
	
tmp/org.txm.core/src/java/org/txm/scripts/importer/SplitBy.groovy (revision 1688)
12 12
	XMLOutputFactory factory = XMLOutputFactory.newInstance();
13 13
	FileOutputStream output;
14 14
	XMLStreamWriter writer;
15
	def parser;
15
	def parser, inputData;
16 16
	ArrayList<String> newfiles = [];
17 17
	
18 18
	public SplitBy(File xmlfile)
19 19
	{
20 20
		try {
21
			def inputData = xmlfile.toURI().toURL().openStream();
21
			inputData = xmlfile.toURI().toURL().openStream();
22 22
			def inputFactory = XMLInputFactory.newInstance();
23 23
			parser = inputFactory.createXMLStreamReader(inputData);
24 24
			
......
60 60
							if(files.contains(newfile))
61 61
							{
62 62
								println "Item declared twice "+filename+" at location "+parser.getLocation();
63
								if (parser != null) parser.close();
64
								if (inputData != null) inputData.close();
63 65
								return false;
64 66
							}
65 67
							files.add(newfile);
......
103 105
				writer.close();
104 106
			if(output != null)
105 107
				output.close();
108
				if (parser != null) parser.close();
109
				if (inputData != null) inputData.close();
106 110
			return true;
107 111
		}
108 112
		catch(Exception e){
109 113
			println "XML Error at location: "+parser.getLocation()
110 114
			e.printStackTrace()
111
			if(writer != null)
115
			if (writer != null)
112 116
				writer.close()
113 117
				output.close()
118
				if (parser != null) parser.close();
119
				if (inputData != null) inputData.close();
114 120
				return false
115 121
			}
116 122
	}
tmp/org.txm.core/src/java/org/txm/scripts/importer/MetadataGetter.groovy (revision 1688)
15 15
					for (int i = 0 ; i < parser.getAttributeCount() ; i++) {
16 16
						if(prop.equals(parser.getAttributeLocalName(i))) {
17 17
							String tmp = parser.getAttributeValue(i)
18
							parser.close()
18
							if (parser != null) parser.close();
19
							if (inputData != null) inputData.close();
19 20
							return tmp
20 21
						}
21 22
					}
22 23
				}
23 24
			}
24 25
		}
25
		parser.close()
26
		if (parser != null) parser.close();
27
		if (inputData != null) inputData.close();
26 28
		return null;
27 29
	}
28 30

  
tmp/org.txm.core/src/java/org/txm/scripts/importer/GetAttributeValue.groovy (revision 1688)
12 12
		String currentpath = "";
13 13
		boolean done = false;
14 14
		
15
		def inputData = null;
16
		def factory = null;
17
		XMLStreamReader parser = null;
15 18
		try {
16 19
			URL url = xmlFile.toURI().toURL();
17
			def inputData = url.openStream();
18
			def factory = XMLInputFactory.newInstance();
19
			XMLStreamReader parser = factory.createXMLStreamReader(inputData);
20
			inputData = url.openStream();
21
			factory = XMLInputFactory.newInstance();
22
			parser = factory.createXMLStreamReader(inputData);
20 23
			for (int event = parser.next(); !done && event != XMLStreamConstants.END_DOCUMENT; event = parser.next())
21 24
			{
22 25
				switch (event) {
......
39 42
					
40 43
				}
41 44
			}
42
			
43 45
		}
44
		catch(Exception e){println("File "+xmlFile+"\n"+e); return "N/A";}
46
		catch(Exception e){println("File "+xmlFile+"\n"+e); 
47
			if (parser != null) parser.close();
48
			if (inputData != null) inputData.close();
49
			return "N/A";}
50
		
51
		if (parser != null) parser.close();
52
		if (inputData != null) inputData.close();
45 53
		return value;
46 54
	}
47 55
}
tmp/org.txm.core/src/java/org/txm/scripts/importer/WExtract.groovy (revision 1688)
255 255
		writer.flush();
256 256
		writer.close();
257 257
		output.close()
258
		inputData.close();
258
		if (parser != null) parser.close();
259
		if (inputData != null) inputData.close();
259 260
	}
260 261
	
261 262
	/**
......
280 281
						count++;
281 282
			}
282 283
		}
283
		inputData.close()
284
		if (parser != null) parser.close();
285
		if (inputData != null) inputData.close();
284 286
		return count;
285 287
	}
286 288
	
tmp/org.txm.core/src/java/org/txm/scripts/importer/WExtractWithMode.groovy (revision 1688)
295 295
		writer.flush();
296 296
		writer.close();
297 297
		output.close()
298
		inputData.close();
298
		if (parser != null) parser.close();
299
		if (inputData != null) inputData.close();
299 300
	}
300 301
	
301 302
	/**
......
320 321
						count++;
321 322
			}
322 323
		}
323
		inputData.close()
324
		if (parser != null) parser.close();
325
		if (inputData != null) inputData.close();
324 326
		return count;
325 327
	}
326 328
	
tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/BuildCwbEncodeArgsFromTEITXM.java (revision 1688)
146 146
		tagattrs.remove("w");//we dont need to report the w tags :) //$NON-NLS-1$
147 147
		tagmax.remove("w"); //$NON-NLS-1$
148 148
		parser.close();
149
		in.close();
149 150
	}
150 151

  
151 152
	/**
tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/imports/URSAnnotationsImporter.java (revision 1688)
396 396
		parser.close();
397 397
		inputData.close();
398 398

  
399

  
400 399
		return false; // standOff not found
401 400
	}
402 401

  
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/BuildFacsEditions.groovy (revision 1688)
159 159
				break;
160 160
			}
161 161
		}
162
		if (parser != null) parser.close();
163
		if (inputData != null) inputData.close();
162 164
		closeMultiWriter()
163 165
		pages << ["$n", wordid] // add the last page (no pb encountered
164 166
		return pages
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/edition/BuildXTZEditions.groovy (revision 1688)
139 139
			}
140 140
		}
141 141
		closeMultiWriter()
142
		if (parser != null) parser.close();
143
		if (inputData != null) inputData.close();
142 144
		return pages
143 145
	}
144 146
}
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/transcription/HTML2TRS.groovy (revision 1688)
250 250
			ret = false;
251 251
		}
252 252
		pagedWriter.close()
253
		if (parser != null) parser.close();
254
		if (inputData != null) inputData.close();
253 255
		return ret
254 256
	}
255 257

  
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/xml/XMLFileStatistics.groovy (revision 1688)
61 61
} catch(Exception e) {
62 62
	println("Unexpected error while parsing file "+inputurl+" : "+e);
63 63
	e.printStackTrace();
64
	parser.close();
64
	if (parser != null) parser.close();
65
	if (inputData != null) inputData.close();
65 66
	return false;
66 67
}
67 68

  
69
if (parser != null) parser.close();
70
if (inputData != null) inputData.close();
71

  
68 72
return paths
69 73

  
70 74
public void processEndElement() {
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/tigersearch/InjectAnnotations.groovy (revision 1688)
196 196
					}
197 197
				}
198 198
				output.close();
199
				parser.close();
199
				
200 200
			} catch (XMLStreamException ex) {
201 201
				System.out.println(ex);
202 202
			} catch (IOException ex) {
203 203
				System.out.println("IOException while parsing " + inputData);
204 204
			}
205 205
		}
206
		if (parser != null) parser.close();
207
		if (inputData != null) inputData.close();
206 208
	}
207 209

  
208 210
	/**
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/tigersearch/BuildTTFile.groovy (revision 1688)
152 152
					}
153 153
				}
154 154
				output.close();
155
				parser.close();
156 155
			} catch (XMLStreamException ex) {
157 156
				System.out.println(ex);
158 157
			} catch (IOException ex) {
159 158
				System.out.println("IOException while parsing " + inputData);
160 159
			}
161 160
		}
161
		if (parser != null) parser.close();
162
		if (inputData != null) inputData.close();
162 163
	}
163 164

  
164 165
	/**
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/compiler.groovy (revision 1688)
341 341
				}
342 342
			}
343 343
			output.close();
344
			parser.close();
344
			if (parser != null) parser.close();
345
		if (inputData != null) inputData.close();
345 346
		}
346
		catch (XMLStreamException ex) {
347
			System.out.println(ex);
347
		catch (Exception ex) {
348
			System.out.println("Exception while parsing " + inputData);
349
			if (parser != null) parser.close();
350
			if (inputData != null) inputData.close();
351
			return false;
348 352
		}
349
		catch (IOException ex) {
350
			System.out.println("IOException while parsing " + inputData);
351
		}
352 353

  
353 354
		return true;
354 355
	}
......
392 393
						}
393 394
				}
394 395
			}
396
			if (parser != null) parser.close();
397
			if (inputData != null) inputData.close();
395 398
		}
396 399
		return new ArrayList<String>(tuprops);
397 400
	}
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/pager.groovy (revision 1688)
447 447
		//writer.write("</html>");
448 448
		//writer.close();
449 449
		closeMultiWriter();
450
		if (parser != null) parser.close();
451
		if (inputData != null) inputData.close();
450 452
	}
451 453
}
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/TRS2SRT.groovy (revision 1688)
57 57
			}
58 58
		}
59 59
		writer.close()
60
		if (parser != null) parser.close();
61
		if (inputData != null) inputData.close();
60 62
	}
61 63

  
62 64
	def speakers = [:]
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/pager.groovy (revision 1688)
652 652
		writer.writeEndElement();
653 653
		writer.close();
654 654
		output.close();
655
		if (parser != null) parser.close();
656
		if (inputData != null) inputData.close();
655 657

  
656 658
		File txmhome = new File(org.txm.Toolbox.getTxmHomePath());
657 659
		File xlsDir  = new File(txmhome, "xsl");
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/compiler.groovy (revision 1688)
557 557
				}
558 558
			}
559 559
		}
560
		parser.close()
561

  
560
		if (parser != null) parser.close();
561
		if (inputData != null) inputData.close();
562
		
562 563
		for (String type : types)
563 564
			if (!anatypes.contains(type))
564 565
				anatypes << type
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/CheckWhos.groovy (revision 1688)
91 91
					}
92 92
			}
93 93
		}
94
		if (parser != null) parser.close();
95
		if (inputData != null) inputData.close();
94 96
		return ret;
95 97
	}
96 98
	
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/alceste/compiler.groovy (revision 1688)
94 94
	 */
95 95
	public compiler(){}
96 96
	
97
	
98
	/**
99
	 * Instantiates a new compiler.
100
	 *
101
	 * @param url the url
102
	 * @param text the text
103
	 * @param base the base
104
	 * @param project the project
105
	 */
106
	public compiler(URL url, String text, String base, String projectName)
107
	{
108
		this.text = text
109
		this.base = base;
110
		try {
111
			this.url = url;
112
			inputData = url.openStream();
113
			
114
			factory = XMLInputFactory.newInstance();
115
			parser = factory.createXMLStreamReader(inputData);
116
		} catch (Exception ex) {
117
			System.err.println("IOException while parsing: "+ex);
118
		}
119
	}
120
	
121 97
	/** The annotation success. */
122 98
	boolean annotationSuccess = false;
123 99
	
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/hyperbase/compiler.groovy (revision 1688)
91 91
	public compiler(){}
92 92
	
93 93
	/**
94
	 * Instantiates a new compiler.
95
	 *
96
	 * @param url the url
97
	 * @param text the text
98
	 * @param base the base
99
	 * @param project the project
100
	 */
101
	public compiler(URL url,String text,String base, String project)
102
	{
103
		this.text = text
104
		this.base = base;
105
		this.project = project;
106
		this.textAttributes = textAttributes;
107
		try {
108
			this.url = url;
109
			inputData = url.openStream();
110
			
111
			factory = XMLInputFactory.newInstance();
112
			parser = factory.createXMLStreamReader(inputData);
113
		} catch (XMLStreamException ex) {
114
			System.out.println(ex);
115
		}catch (IOException ex) {
116
			System.err.println("IOException while parsing ");
117
		}
118
	}
119
	
120
	/**
121 94
	 * set the language of the corpus.
122 95
	 *
123 96
	 * @param lang the lang
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZCompilerStep.groovy (revision 1688)
256 256
			}
257 257

  
258 258
			output.close();
259
			parser.close();
259
			if (parser != null) parser.close();
260
		if (inputData != null) inputData.close();
260 261
		} catch (Exception ex) {
261 262
			System.out.println("Exception while parsing " + inputData+" of Text "+textname+" : "+ex);
262 263
			File errorDir = null
......
268 269
			} catch(Exception eCopy) {
269 270
				println "Error while moving "+xmlFile+" to "+errorDir+" : "+eCopy
270 271
			}
272
			if (parser != null) parser.close();
273
			if (inputData != null) inputData.close();
271 274
			return false;
272 275
		}
273 276
		return true;
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZFacsPagerStep.groovy (revision 1688)
242 242
			}
243 243
		}
244 244
		closeMultiWriter()
245
		if (parser != null) parser.close();
246
		if (inputData != null) inputData.close();
245 247
		pages << [htmlFile, wordid] // add the last page (no pb encountered
246 248

  
247 249
		return pages.size() > 1
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZCompiler.groovy (revision 1688)
115 115
				}	
116 116
			}
117 117
		}
118
		parser.close()
119

  
118
		
119
		if (parser != null) parser.close();
120
		if (inputData != null) inputData.close();
121
		
120 122
//		for (String type : types)
121 123
//			if (!anatypes.contains(type))
122 124
//				anatypes << type
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZPager.groovy (revision 1688)
454 454
				}
455 455
			}
456 456
		}
457
		parser.close()
457
		if (parser != null) parser.close();
458
		if (inputData != null) inputData.close();
458 459

  
459 460
		return content;
460 461
	}
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZDefaultPagerStep.groovy (revision 1688)
574 574
				}
575 575
			}
576 576
			closeMultiWriter();
577
			if (parser != null) parser.close();
578
			if (inputData != null) inputData.close();
577 579
		} catch(Exception e) {
578 580
			println "** Fail to build $infile edition: $e at "+parser.getLocation()
579 581
			println "** resulting file: $outfile"
580 582
			println "** Stax stack: "+pagedWriter.getTagStack()
581 583
			e.printStackTrace();
582 584
			pagedWriter.close()
585
			if (parser != null) parser.close();
586
			if (inputData != null) inputData.close();
583 587
			return false;
584 588
		}
585 589
		return true;
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xmltxm/compiler.groovy (revision 1688)
321 321
			}
322 322

  
323 323
			output.close();
324
			parser.close();
324
			if (parser != null) parser.close();
325
		if (inputData != null) inputData.close();
325 326
		}
326 327
		catch (Exception ex) {
327 328
			System.out.println("Error while writing CQP file $ex");
328 329
			ex.printStackTrace();
330
			if (parser != null) parser.close();
331
			if (inputData != null) inputData.close();
329 332
			return false;
330 333
		}
331 334
		return true;
......
511 514
				}
512 515
			}
513 516
		}
514
		parser.close()
517
		
518
		if (parser != null) parser.close();
519
		if (inputData != null) inputData.close();
515 520

  
516 521
		for (String type : types)
517 522
			if (!anatypes.contains(type))
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/discours/compiler.groovy (revision 1688)
89 89
	}
90 90

  
91 91
	/**
92
	 * Instantiates a new compiler.
93
	 *
94
	 * @param url the url
95
	 * @param text the text
96
	 * @param base the base
97
	 * @param project the project
98
	 */
99
	public compiler(URL url,String text,String base, String projectName) {
100
		this.text = text
101
		this.base = base;
102
		try {
103
			this.url = url;
104
			inputData = url.openStream();
105

  
106
			factory = XMLInputFactory.newInstance();
107
			parser = factory.createXMLStreamReader(inputData);
108
		} catch (XMLStreamException ex) {
109
			System.out.println(ex);
110
		}catch (IOException ex) {
111
			System.err.println("IOException while parsing ");
112
		}
113
	}
114

  
115
	/**
116 92
	 * set the language of the corpus.
117 93
	 *
118 94
	 * @param lang the lang
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xmltxmpara/compiler.groovy (revision 1688)
323 323
			}
324 324
			
325 325
			output.close();
326
			parser.close();
326
			if (parser != null) parser.close();
327
			if (inputData != null) inputData.close();
327 328
		}
328
		catch (XMLStreamException ex) {
329
		catch (Exception ex) {
329 330
			System.out.println(ex);
331
			if (parser != null) parser.close();
332
			if (inputData != null) inputData.close();
330 333
			return false;
331 334
		}
332
		catch (IOException ex) {
333
			System.out.println("IOException while parsing " + inputData);
334
			return false;
335
		}
336 335
		return true;
337 336
	}
338 337
	
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xmltxmpara/ValidateXmlTXM.groovy (revision 1688)
70 70
				}
71 71
			}
72 72
		}
73
		parser.close();
73
		if (parser != null) parser.close();
74
		if (inputData != null) inputData.close();
74 75
		println "get infos from $alignxml"
75 76
		return true;
76 77
	}
......
103 104

  
104 105
			factory = XMLInputFactory.newInstance();
105 106
			parser = factory.createXMLStreamReader(inputData);
106
		} catch (XMLStreamException ex) {
107
			System.out.println(ex);
108
			return false;
109
		}catch (IOException ex) {
110
			System.err.println("IOException while parsing ");
111
			return false
112
		}
107
		
113 108
		String localname = ""
114 109
		for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next())
115 110
		{
......
186 181
				}
187 182
			}
188 183
		}
189
		parser.close();
190
		
184
		if (parser != null) parser.close();
185
			if (inputData != null) inputData.close();
186
		} catch (XMLStreamException ex) {
187
			System.out.println(ex);
188
			if (parser != null) parser.close();
189
			if (inputData != null) inputData.close();
190
			return false;
191
		}
191 192
		if(checkteiCorpus &
192 193
			!(hasTeiCorpus & hasTeiCorpusID & hasTeiCorpusHeader & hasTeiCorpusHeaderVersion))
193 194
		{	println "wrong <teiCorpus> format: $hasTeiCorpus & $hasTeiCorpusID & $hasTeiCorpusHeader & $hasTeiCorpusHeaderVersion"
......
197 198
		if(checkAlignStruct &
198 199
			!hasAlignStruct)
199 200
		{   println "wrong align structure format: $hasAlignStruct"
201
			if (parser != null) parser.close();
202
			if (inputData != null) inputData.close();
200 203
			return false;
201 204
		}
202 205
		
203 206
		if(checkTEI & !(hasTei == hasTeiID))
204 207
		{	println "wrong <TEI> format: $hasTei == $hasTeiID"
208
			if (parser != null) parser.close();
209
			if (inputData != null) inputData.close();
205 210
			return false;
206 211
		}
207 212
		
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xml/compiler.groovy (revision 1688)
384 384
			}
385 385
			//output.write("</txmcorpus>");
386 386
			output.close();
387
			parser.close();
387
			if (parser != null) parser.close();
388
		if (inputData != null) inputData.close();
388 389
		} catch (Exception ex) {
389 390
			System.out.println("Exception while parsing " + inputData+" of Text "+text);
390 391
			File xmlFile = null
......
398 399
			} catch(Exception eCopy) {
399 400
				println "Error while moving "+url+" to "+errorDir
400 401
			}
402
			if (parser != null) parser.close();
403
			if (inputData != null) inputData.close();
401 404
			return false;
402 405
		}
403 406
		return true;
......
421 424
				}
422 425
			}
423 426
		}
424
		parser.close()
427
		
428
		if (parser != null) parser.close();
429
		if (inputData != null) inputData.close();
425 430

  
426 431
		for (String type : types)
427 432
			if (!anatypes.contains(type))
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xml/pager_old.groovy (revision 1688)
366 366
		//writer.write("</html>");
367 367
		//writer.close();
368 368
		closeMultiWriter();
369
		if (parser != null) parser.close();
370
		if (inputData != null) inputData.close();
369 371
	}
370 372
}
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xml/pager.groovy (revision 1688)
449 449
			}
450 450
		}
451 451
		closeMultiWriter();
452
		if (parser != null) parser.close();
453
		if (inputData != null) inputData.close();
452 454
	}
453 455
}
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/bfm/compiler.groovy (revision 1688)
727 727
			inputData.close();
728 728
		} catch (Exception ex) {
729 729
			System.out.println("Exception while parsing " + inputData);
730
			ex.printStackTrace();
730
			ex.printStackTrace();
731
			if (output != null) output.close();
732
			if (parser != null) parser.close();
733
			if (inputData != null) inputData.close();
731 734
			return false;
732 735
		}
733 736

  
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/bfm/pager.groovy (revision 1688)
541 541
							interpvalue += (parser.getText());
542 542
					break;
543 543
			}
544
		}
544
		}
545
		if (parser != null) parser.close();
546
		if (inputData != null) inputData.close();
545 547
		closeMultiWriter();
546 548
	}
547 549
}
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/doc/pager.groovy (revision 1688)
476 476
			//writer.write("</html>");
477 477
			//writer.close();
478 478
			closeMultiWriter();
479
			if (parser != null) parser.close();
480
			if (inputData != null) inputData.close();
479 481
		} catch(Exception e) { 
480 482
			println "Error while processing ${infile} at "+parser.getLocation().getLineNumber()+": "+e
481 483
			org.txm.utils.logger.Log.printStackTrace(e); 
482
			pagedWriter.close(); }
484
			pagedWriter.close();
485
			if (parser != null) parser.close();
486
			if (inputData != null) inputData.close();
487
		 }
483 488
	}
484 489
}
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/filters/Tokeniser/FastSimpleTokenizerXml.groovy (revision 1688)
425 425
		} catch (Exception e) {
426 426
			System.err.println("Error : "+infile);
427 427
			e.printStackTrace();
428
			if (writer != null) writer.close();
429
			if (output != null) output.close();
430
			if (parser != null) parser.close();
431
			if (inputData != null) inputData.close();
428 432
			return false;
429 433
		}
430 434
		return true;
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/filters/Tokeniser/SimpleTokenizerXml.groovy (revision 1688)
456 456
		} catch (Exception e) {
457 457
			System.err.println("Error : "+infile);
458 458
			e.printStackTrace();
459
			if (writer != null) writer.close();
460
			if (output != null) output.close();
461
			if (parser != null) parser.close();
462
			if (inputData != null) inputData.close();
459 463
			return false;
460 464
		}
461 465
		return true;
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/filters/Tokeniser/TokenizerXml.groovy (revision 1688)
366 366
			}
367 367
		}
368 368
		
369
		parser.close()

370
		writer.close();

371
		output.close();

372
		inputData.close();
369
		if (writer != null) writer.close();
370
			if (output != null) output.close();
371
			if (parser != null) parser.close();
372
			if (inputData != null) inputData.close();
373 373
	}
374 374
	
375 375
	/**
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/filters/Tokeniser/OneTagPerLine.groovy (revision 1688)
232 232
							break;
233 233
					}
234 234
				}
235
				output.close();
236
				parser.close();
235
			if (output != null) output.close();
236
			if (parser != null) parser.close();
237
			if (inputData != null) inputData.close();
237 238

  
238 239
				Reader input = new InputStreamReader(new FileInputStream(outfile) , "UTF-8");
239 240
				File temp = new File(outfile.getParent(),"temp");
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/filters/TagSentences/TagSentencesXml.groovy (revision 1688)
186 186
			
187 187
			writer.close()
188 188
			output.close()
189
			parser.close()
189
			if (parser != null) parser.close();
190
		if (inputData != null) inputData.close();
190 191
		} catch (Exception ex) {
191 192
			System.err.println(parser.getLocation().toString());
192 193
			ex.printStackTrace();
193 194
			
194 195
			writer.close()
195 196
			output.close()
196
			parser.close()
197
			if (parser != null) parser.close();
198
		if (inputData != null) inputData.close();
197 199
			return false;
198 200
		}
199 201

  
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/nlp/XMLStaxTokenizerAdapter2.groovy (revision 1688)
70 70
			println("Error while parsing file "+inputurl);
71 71
			println("Location "+parser.getLocation());
72 72
			org.txm.utils.logger.Log.printStackTrace(e);
73
			parser.close();
73
			if (parser != null) parser.close();
74
			if (inputData != null) inputData.close();
74 75
			return false;
75 76
		}
76 77

  
77
		if (parser !=null) parser.close();
78
		if (parser != null) parser.close();
79
		if (inputData != null) inputData.close();
78 80
		return true;
79 81
	}
80 82

  
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/swb/FindUnclosedTag.groovy (revision 1688)
34 34
	println "** at lines: "+locations
35 35
}
36 36

  
37
if (parser != null) parser.close();
38
if (inputData != null) inputData.close();
39

  
37 40
public boolean startElement(String localname, def loc) {
38 41
	println structPath
39 42
	structPath += localname+"/"
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/swb/CountNumberOfChar.groovy (revision 1688)
78 78
						}
79 79
				}
80 80
			}
81

  
81
			
82
			if (parser != null) parser.close();
83
			if (inputData != null) inputData.close();
82 84
		}
83 85
		catch(Exception e){e.printStackTrace();}
84 86
	}
tmp/org.txm.treetagger.core/src/org/txm/importer/xmltxm/AnnotationInjectionFromTTOutput.groovy (revision 1688)
136 136
			}
137 137
		}
138 138
		headerparser.close();
139
		anainputData.close();
139 140
	}
140 141

  
141 142
	/**
......
165 166
			}
166 167
		}
167 168
		anaparser.close();
169
		anainputData.close();
168 170
		return links;
169 171
	}
170 172

  
......
225 227
				}
226 228
			}
227 229
		}
230
		anaparser.close();
228 231
		return "";
229 232
	}
230 233

  
tmp/org.txm.dictionary.rcp/src/org/txm/macro/frolex/LGerm2CLDMFTSVMacro.groovy (revision 1688)
202 202
		//e.printStackTrace()
203 203

  
204 204
		parser.close()
205
		inputData.close()
205 206
		return false
206 207
	}
207 208

  
tmp/org.txm.dictionary.rcp/src/org/txm/macro/frolex/LGerm2DMFTSVMacro.groovy (revision 1688)
163 163
		//e.printStackTrace()
164 164

  
165 165
		parser.close()
166
		inputData.close()
166 167
		return false
167 168
	}
168 169

  
tmp/org.txm.core.tests/src/org/txm/core/tests/junit/PluginsManifest.java (revision 1688)
2 2

  
3 3
import java.io.File;
4 4
import java.io.IOException;
5
import java.io.InputStream;
5 6
import java.util.HashMap;
6 7
import java.util.jar.Attributes;
7 8
import java.util.jar.Manifest;
......
39 40
		
40 41
		File manifestFixFile = new File(projectDirectory, "META-INF/MANIFEST-FIX.MF");
41 42
		
42
		Manifest manifest = new Manifest(manifestFile.toURI().toURL().openStream());
43
		InputStream inputData = manifestFile.toURI().toURL().openStream();
44
		Manifest manifest = new Manifest(inputData);
43 45
		Attributes attributes = manifest.getMainAttributes();
44 46
		for (Object k : attributes.keySet()) {
45 47
			if (k.toString().equals("Require-Bundle")) {
......
68 70
		if (massFix) {
69 71
			manifest.write(IOUtils.getOutputStream(manifestFile));
70 72
		}
73
		inputData.close();
71 74
	}
72 75

  
73 76
	@Override

Also available in: Unified diff