| | 335 | /** |
| | 336 | * Creae a stream result based on a File. |
| | 337 | * Other than the default implementation not only the File is used to |
| | 338 | * initialize the result, but also a Stream is opened and initialized. |
| | 339 | * This works around an issue with whitespaces in the pathname which |
| | 340 | * otherwise would lead to a file not found exception |
| | 341 | * <pre> |
| | 342 | * Error during transformation: javax.xml.transform.TransformerException: java.io.FileNotFoundException: ...%20... |
| | 343 | * at org.apache.xalan.transformer.TransformerImpl.createSerializationHandler(TransformerImpl.java:1218) |
| | 344 | * at org.apache.xalan.transformer.TransformerImpl.createSerializationHandler(TransformerImpl.java:1060) |
| | 345 | * at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1268) |
| | 346 | * at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1251) |
| | 347 | * .... |
| | 348 | * </pre>. |
| | 349 | * The caller must ensure that the created outputstream is closed. |
| | 350 | * @param outFile the file to be used in the stream result. |
| | 351 | * @return a new StreamResult piontint to the given File. |
| | 352 | * @throws IOException in case of an issue while creating the stream. |
| | 353 | */ |
| | 354 | public static StreamResult createStreamResult(File outFile) |
| | 355 | throws IOException |
| | 356 | { |
| | 357 | final StreamResult result = new StreamResult(outFile); |
| | 358 | // set the stream directly to avoid issues with blanks in the |
| | 359 | // filename. |
| | 360 | result.setOutputStream(new FileOutputStream(outFile)); |
| | 361 | return result; |
| | 362 | } |
| | 363 | |