Repository: cxf Updated Branches: refs/heads/master e647cb1f8 -> f3304a89a
Removing FileInput/OutputStream Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/f3304a89 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/f3304a89 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/f3304a89 Branch: refs/heads/master Commit: f3304a89a7e93e9c466ee5dbd8d97ffe2d50f50f Parents: 1329e2c Author: Colm O hEigeartaigh <cohei...@apache.org> Authored: Mon Apr 24 15:59:10 2017 +0100 Committer: Colm O hEigeartaigh <cohei...@apache.org> Committed: Mon Apr 24 15:59:34 2017 +0100 ---------------------------------------------------------------------- .../cxf/attachment/ImageDataContentHandler.java | 4 ++-- .../apache/cxf/configuration/jsse/SSLUtils.java | 16 ++++++------- .../jsse/TLSParameterJaxBUtils.java | 10 ++++---- .../java/org/apache/cxf/helpers/FileUtils.java | 3 +-- .../java/org/apache/cxf/helpers/IOUtils.java | 6 ++--- .../org/apache/cxf/io/CachedOutputStream.java | 10 ++++---- .../java/org/apache/cxf/io/CachedWriter.java | 6 ++--- .../org/apache/cxf/resource/URIResolver.java | 4 ++-- .../org/apache/cxf/staxutils/StaxUtils.java | 4 ++-- .../maven_plugin/wsdl2java/WSDL2JavaMojo.java | 7 +++--- .../maven_plugin/javatowadl/DumpJavaDoc.java | 12 ++++++---- .../javatowadl/ResourceMapJavaDocProvider.java | 10 ++++---- .../cxf/binding/corba/utils/OrbConfig.java | 5 ++-- .../cxf/jaxrs/provider/BinaryDataProvider.java | 11 ++++----- .../cxf/jaxrs/provider/MultipartProvider.java | 4 ++-- .../endpoint/dynamic/DynamicClientFactory.java | 10 ++++---- .../persistence/FilesystemExchangeDataDAO.java | 5 ++-- .../httpclient/PublicSuffixMatcherLoader.java | 4 ++-- .../x509/repo/file/FileCertificateRepo.java | 24 +++++++++++--------- .../cxf/testutil/common/ServerLauncher.java | 12 ++++++---- .../org/apache/cxf/tools/common/ClassUtils.java | 9 ++++---- .../org/apache/cxf/tools/util/JAXBUtils.java | 13 ++++++----- .../cxf/tools/util/OutputStreamCreator.java | 4 ++-- .../apache/cxf/tools/util/ToolsStaxUtils.java | 8 +++---- .../cxf/tools/corba/common/SchemaFactory.java | 9 ++++---- .../tools/corba/common/WSDLCorbaFactory.java | 9 ++++---- .../corba/utils/FileOutputStreamFactory.java | 7 +++--- .../java2js/processor/JavaToJSProcessor.java | 9 ++++---- .../generator/wsdl11/WSDL11Generator.java | 4 ++-- .../tools/wadlto/jaxb/CustomizationParser.java | 4 ++-- .../cxf/tools/wadlto/jaxrs/SourceGenerator.java | 4 ++-- .../cxf/tools/wsdlto/WSDLToJavaContainer.java | 11 ++++----- .../databinding/jaxb/JAXBDataBinding.java | 7 +++--- .../javascript/WSDLToJavaScriptProcessor.java | 9 ++++---- .../customization/CustomizationParser.java | 4 ++-- .../misc/processor/XSDToWSDLProcessor.java | 5 ++-- 36 files changed, 149 insertions(+), 134 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/core/src/main/java/org/apache/cxf/attachment/ImageDataContentHandler.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/attachment/ImageDataContentHandler.java b/core/src/main/java/org/apache/cxf/attachment/ImageDataContentHandler.java index 2b28980..f007377 100644 --- a/core/src/main/java/org/apache/cxf/attachment/ImageDataContentHandler.java +++ b/core/src/main/java/org/apache/cxf/attachment/ImageDataContentHandler.java @@ -27,10 +27,10 @@ import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.image.BufferedImage; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Files; import java.util.Iterator; import javax.activation.ActivationDataFlavor; @@ -98,7 +98,7 @@ public class ImageDataContentHandler implements DataContentHandler { } else if (obj instanceof InputStream) { IOUtils.copyAndCloseInput((InputStream)obj, os); } else if (obj instanceof File) { - FileInputStream file = new FileInputStream((File)obj); + InputStream file = Files.newInputStream(((File)obj).toPath()); IOUtils.copyAndCloseInput(file, os); } else { throw new IOException("Attachment type not spported " + obj.getClass()); http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java b/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java index 1bf116b..99716f1 100644 --- a/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java +++ b/core/src/main/java/org/apache/cxf/configuration/jsse/SSLUtils.java @@ -21,8 +21,8 @@ package org.apache.cxf.configuration.jsse; import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; @@ -96,7 +96,7 @@ public final class SSLUtils { String location = getKeystore(null, log); String keyStorePassword = getKeystorePassword(null, log); String keyPassword = getKeyPassword(null, log); - FileInputStream fis = null; + InputStream is = null; try { File file = new File(location); @@ -105,8 +105,8 @@ public final class SSLUtils { KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); - fis = new FileInputStream(file); - ks.load(fis, (keyStorePassword != null) ? keyStorePassword.toCharArray() : null); + is = Files.newInputStream(file.toPath()); + ks.load(is, (keyStorePassword != null) ? keyStorePassword.toCharArray() : null); kmf.init(ks, (keyPassword != null) ? keyPassword.toCharArray() : null); defaultManagers = kmf.getKeyManagers(); } else { @@ -117,9 +117,9 @@ public final class SSLUtils { log.log(Level.WARNING, "Default key managers cannot be initialized: " + e.getMessage(), e); defaultManagers = new KeyManager[0]; } finally { - if (fis != null) { + if (is != null) { try { - fis.close(); + is.close(); } catch (IOException e) { log.warning("Keystore stream cannot be closed: " + e.getMessage()); } @@ -454,7 +454,7 @@ public final class SSLUtils { LogUtils.log(log, Level.FINE, logMsg, trustStoreType); return trustStoreType; } - + public static String getTruststorePassword(String trustStorePassword, Logger log) { String logMsg = null; @@ -470,7 +470,7 @@ public final class SSLUtils { LogUtils.log(log, Level.FINE, logMsg); return trustStorePassword; } - + public static String getTruststoreProvider(String trustStoreProvider, Logger log) { String logMsg = null; if (trustStoreProvider != null) { http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/core/src/main/java/org/apache/cxf/configuration/jsse/TLSParameterJaxBUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/configuration/jsse/TLSParameterJaxBUtils.java b/core/src/main/java/org/apache/cxf/configuration/jsse/TLSParameterJaxBUtils.java index 8057a68..b2e5ce0 100644 --- a/core/src/main/java/org/apache/cxf/configuration/jsse/TLSParameterJaxBUtils.java +++ b/core/src/main/java/org/apache/cxf/configuration/jsse/TLSParameterJaxBUtils.java @@ -18,10 +18,11 @@ */ package org.apache.cxf.configuration.jsse; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; import java.security.GeneralSecurityException; import java.security.KeyStore; import java.security.KeyStoreException; @@ -147,7 +148,7 @@ public final class TLSParameterJaxBUtils { : KeyStore.getInstance(type, provider); if (kst.isSetFile()) { - try (FileInputStream kstInputStream = new FileInputStream(kst.getFile())) { + try (InputStream kstInputStream = Files.newInputStream(Paths.get(kst.getFile()))) { keyStore.load(kstInputStream, password); } } else if (kst.isSetResource()) { @@ -164,7 +165,7 @@ public final class TLSParameterJaxBUtils { } else { String loc = SSLUtils.getKeystore(null, LOG); if (loc != null) { - try (InputStream ins = new FileInputStream(loc)) { + try (InputStream ins = Files.newInputStream(Paths.get(loc))) { keyStore.load(ins, password); } } @@ -188,7 +189,8 @@ public final class TLSParameterJaxBUtils { type = KeyStore.getDefaultType(); } if (pst.isSetFile()) { - return createTrustStore(new FileInputStream(pst.getFile()), type); + InputStream is = Files.newInputStream(Paths.get(pst.getFile())); + return createTrustStore(is, type); } if (pst.isSetResource()) { final InputStream is = getResourceAsStream(pst.getResource()); http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/core/src/main/java/org/apache/cxf/helpers/FileUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java index 5ebb23d..ec3b433 100644 --- a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java +++ b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java @@ -21,7 +21,6 @@ package org.apache.cxf.helpers; import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; @@ -304,7 +303,7 @@ public final class FileUtils { String result = null; try { - is = new FileInputStream(location); + is = Files.newInputStream(location.toPath()); result = normalizeCRLF(is); } catch (Exception e) { e.printStackTrace(); http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/core/src/main/java/org/apache/cxf/helpers/IOUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/helpers/IOUtils.java b/core/src/main/java/org/apache/cxf/helpers/IOUtils.java index 4fe9508..e474a09 100644 --- a/core/src/main/java/org/apache/cxf/helpers/IOUtils.java +++ b/core/src/main/java/org/apache/cxf/helpers/IOUtils.java @@ -22,7 +22,6 @@ package org.apache.cxf.helpers; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -32,6 +31,7 @@ import java.io.Reader; import java.io.UnsupportedEncodingException; import java.io.Writer; import java.nio.charset.Charset; +import java.nio.file.Files; import org.apache.cxf.io.CopyingOutputStream; import org.apache.cxf.io.Transferable; @@ -274,8 +274,8 @@ public final class IOUtils { if (Transferable.class.isAssignableFrom(inputStream.getClass())) { ((Transferable)inputStream).transferTo(destinationFile); } else { - try (FileOutputStream fout = new FileOutputStream(destinationFile)) { - copyAndCloseInput(inputStream, fout); + try (OutputStream out = Files.newOutputStream(destinationFile.toPath())) { + copyAndCloseInput(inputStream, out); } } } http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java b/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java index 1865b84..5c79fc0 100644 --- a/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java +++ b/core/src/main/java/org/apache/cxf/io/CachedOutputStream.java @@ -25,13 +25,13 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.Reader; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.security.GeneralSecurityException; import java.util.ArrayList; import java.util.Collections; @@ -595,7 +595,7 @@ public class CachedOutputStream extends OutputStream { } private OutputStream createOutputStream(File file) throws IOException { - OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); + OutputStream out = new BufferedOutputStream(Files.newOutputStream(file.toPath())); if (cipherTransformation != null) { try { if (ciphers == null) { @@ -618,7 +618,7 @@ public class CachedOutputStream extends OutputStream { } private InputStream createInputStream(File file) throws IOException { - InputStream in = new FileInputStream(file); + InputStream in = Files.newInputStream(file.toPath()); if (cipherTransformation != null) { in = new CipherInputStream(in, ciphers.getDecryptor()) { boolean closed; @@ -660,8 +660,8 @@ public class CachedOutputStream extends OutputStream { if (!transfered) { // Data is in memory, or we failed to rename the file, try copying // the stream instead. - try (FileOutputStream fout = new FileOutputStream(destinationFile)) { - IOUtils.copyAndCloseInput(this, fout); + try (OutputStream out = Files.newOutputStream(destinationFile.toPath())) { + IOUtils.copyAndCloseInput(this, out); } } } http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/core/src/main/java/org/apache/cxf/io/CachedWriter.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/io/CachedWriter.java b/core/src/main/java/org/apache/cxf/io/CachedWriter.java index 11f870f..64be62e 100644 --- a/core/src/main/java/org/apache/cxf/io/CachedWriter.java +++ b/core/src/main/java/org/apache/cxf/io/CachedWriter.java @@ -25,7 +25,6 @@ import java.io.CharArrayWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -34,6 +33,7 @@ import java.io.OutputStreamWriter; import java.io.Reader; import java.io.Writer; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.security.GeneralSecurityException; import java.util.ArrayList; import java.util.Collections; @@ -599,7 +599,7 @@ public class CachedWriter extends Writer { } private OutputStreamWriter createOutputStreamWriter(File file) throws IOException { - OutputStream out = new BufferedOutputStream(new FileOutputStream(file)); + OutputStream out = new BufferedOutputStream(Files.newOutputStream(file.toPath())); if (cipherTransformation != null) { try { if (ciphers == null) { @@ -629,7 +629,7 @@ public class CachedWriter extends Writer { } private InputStreamReader createInputStreamReader(File file) throws IOException { - InputStream in = new FileInputStream(file); + InputStream in = Files.newInputStream(file.toPath()); if (cipherTransformation != null) { in = new CipherInputStream(in, ciphers.getDecryptor()) { boolean closed; http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/core/src/main/java/org/apache/cxf/resource/URIResolver.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/resource/URIResolver.java b/core/src/main/java/org/apache/cxf/resource/URIResolver.java index 60ae0fe..0199358 100644 --- a/core/src/main/java/org/apache/cxf/resource/URIResolver.java +++ b/core/src/main/java/org/apache/cxf/resource/URIResolver.java @@ -19,7 +19,6 @@ package org.apache.cxf.resource; import java.io.File; -import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; @@ -30,6 +29,7 @@ import java.net.URISyntaxException; import java.net.URL; import java.net.URLConnection; import java.net.URLDecoder; +import java.nio.file.Files; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashMap; @@ -250,7 +250,7 @@ public class URIResolver { if (is == null && file != null && file.exists()) { uri = file.toURI(); try { - is = new FileInputStream(file); + is = Files.newInputStream(file.toPath()); } catch (FileNotFoundException e) { throw new RuntimeException("File was deleted! " + uriStr, e); } http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java b/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java index 00d8f53..ff9d284 100644 --- a/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java +++ b/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java @@ -20,7 +20,6 @@ package org.apache.cxf.staxutils; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -29,6 +28,7 @@ import java.io.StringWriter; import java.io.Writer; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; @@ -1160,7 +1160,7 @@ public final class StaxUtils { } } public static Document read(File is) throws XMLStreamException, IOException { - try (InputStream fin = new FileInputStream(is)) { + try (InputStream fin = Files.newInputStream(is.toPath())) { return read(fin); } } http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java ---------------------------------------------------------------------- diff --git a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java index 5c483f8..618f462 100644 --- a/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java +++ b/maven-plugins/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/wsdl2java/WSDL2JavaMojo.java @@ -22,13 +22,12 @@ package org.apache.cxf.maven_plugin.wsdl2java; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashSet; @@ -241,7 +240,7 @@ public class WSDL2JavaMojo extends AbstractCodegenMoho { String options = wsdlOption.generateCommandLine(null, basedir, wsdlURI, false).toString(); DataInputStream reader = null; try { - reader = new DataInputStream(new FileInputStream(doneFile)); + reader = new DataInputStream(Files.newInputStream(doneFile.toPath())); String s = reader.readUTF(); if (!options.equals(s)) { doWork = true; @@ -265,7 +264,7 @@ public class WSDL2JavaMojo extends AbstractCodegenMoho { doneFile.createNewFile(); URI basedir = project.getBasedir().toURI(); String options = wsdlOption.generateCommandLine(null, basedir, wsdlURI, false).toString(); - try (DataOutputStream writer = new DataOutputStream(new FileOutputStream(doneFile))) { + try (DataOutputStream writer = new DataOutputStream(Files.newOutputStream(doneFile.toPath()))) { writer.writeUTF(options); writer.flush(); } http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/DumpJavaDoc.java ---------------------------------------------------------------------- diff --git a/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/DumpJavaDoc.java b/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/DumpJavaDoc.java index f37a06a..c84eade 100644 --- a/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/DumpJavaDoc.java +++ b/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/DumpJavaDoc.java @@ -18,8 +18,10 @@ */ package org.apache.cxf.maven_plugin.javatowadl; -import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Properties; import com.sun.javadoc.ClassDoc; @@ -38,7 +40,7 @@ public final class DumpJavaDoc { public static boolean start(RootDoc root) throws IOException { String dumpFileName = readOptions(root.options()); - FileOutputStream fos = new FileOutputStream(dumpFileName); + OutputStream os = Files.newOutputStream(Paths.get(dumpFileName)); Properties javaDocMap = new Properties(); for (ClassDoc classDoc : root.classes()) { javaDocMap.put(classDoc.toString(), classDoc.commentText()); @@ -62,9 +64,9 @@ public final class DumpJavaDoc { } } - javaDocMap.store(fos, ""); - fos.flush(); - fos.close(); + javaDocMap.store(os, ""); + os.flush(); + os.close(); return true; } http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/ResourceMapJavaDocProvider.java ---------------------------------------------------------------------- diff --git a/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/ResourceMapJavaDocProvider.java b/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/ResourceMapJavaDocProvider.java index abe5c90..86d2c49 100644 --- a/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/ResourceMapJavaDocProvider.java +++ b/maven-plugins/java2wadl-plugin/src/main/java/org/apache/cxf/maven_plugin/javatowadl/ResourceMapJavaDocProvider.java @@ -18,8 +18,10 @@ */ package org.apache.cxf.maven_plugin.javatowadl; -import java.io.FileInputStream; +import java.io.InputStream; import java.lang.reflect.Method; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Properties; import java.util.logging.Logger; @@ -38,10 +40,10 @@ public class ResourceMapJavaDocProvider implements DocumentationProvider { public ResourceMapJavaDocProvider(String targetFolder) { dumpedDocFile = new Properties(); - try (FileInputStream fis = new FileInputStream(targetFolder + "/site/apidocs/dumpFile.properties")) { - dumpedDocFile.load(fis); + try (InputStream is = Files.newInputStream(Paths.get(targetFolder + "/site/apidocs/dumpFile.properties"))) { + dumpedDocFile.load(is); } catch (Exception e) { - LOG.warning("can't load dumped Docomentation file" + e.getMessage()); + LOG.warning("can't load dumped Documentation file" + e.getMessage()); } } http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/OrbConfig.java ---------------------------------------------------------------------- diff --git a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/OrbConfig.java b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/OrbConfig.java index e96bbb7..f91deeb 100644 --- a/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/OrbConfig.java +++ b/rt/bindings/corba/src/main/java/org/apache/cxf/binding/corba/utils/OrbConfig.java @@ -20,12 +20,13 @@ package org.apache.cxf.binding.corba.utils; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.io.PrintWriter; import java.lang.reflect.Method; import java.net.URI; import java.net.URISyntaxException; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import java.util.Properties; @@ -182,7 +183,7 @@ public class OrbConfig { } else { f = new File(iorFile); } - try (FileOutputStream file = new FileOutputStream(f); + try (OutputStream file = Files.newOutputStream(f.toPath()); PrintWriter out = new PrintWriter(file)) { out.println(ref); out.flush(); http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java index 6e9fdd9..0b8ad53 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java @@ -22,8 +22,6 @@ package org.apache.cxf.jaxrs.provider; import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -34,6 +32,7 @@ import java.io.Writer; import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.security.DigestInputStream; import java.util.UUID; import java.util.logging.Logger; @@ -123,9 +122,9 @@ public class BinaryDataProvider<T> extends AbstractConfigurableProvider "jaxrs", null, true); - FileOutputStream fos = new FileOutputStream(f); - IOUtils.copy(is, fos, bufferSize); - fos.close(); + OutputStream os = Files.newOutputStream(f.toPath()); + IOUtils.copy(is, os, bufferSize); + os.close(); return clazz.cast(f); } if (StreamingOutput.class.isAssignableFrom(clazz)) { @@ -166,7 +165,7 @@ public class BinaryDataProvider<T> extends AbstractConfigurableProvider copyInputToOutput((InputStream)o, os, annotations, headers); } else if (File.class.isAssignableFrom(o.getClass())) { copyInputToOutput(new BufferedInputStream( - new FileInputStream((File)o)), os, annotations, headers); + Files.newInputStream(((File)o).toPath())), os, annotations, headers); } else if (byte[].class.isAssignableFrom(o.getClass())) { copyInputToOutput(new ByteArrayInputStream((byte[])o), os, annotations, headers); } else if (Reader.class.isAssignableFrom(o.getClass())) { http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java ---------------------------------------------------------------------- diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java index 6de865f..95ad0cb 100644 --- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java +++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java @@ -20,12 +20,12 @@ package org.apache.cxf.jaxrs.provider; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.lang.annotation.Annotation; import java.lang.reflect.Type; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -343,7 +343,7 @@ public class MultipartProvider extends AbstractConfigurableProvider File f = (File)obj; ContentDisposition cd = mainMediaType.startsWith(MediaType.MULTIPART_FORM_DATA) ? new ContentDisposition("form-data;name=file;filename=" + f.getName()) : null; - return new Attachment(AttachmentUtil.BODY_ATTACHMENT_ID, new FileInputStream(f), cd); + return new Attachment(AttachmentUtil.BODY_ATTACHMENT_ID, Files.newInputStream(f.toPath()), cd); } else if (Attachment.class.isAssignableFrom(obj.getClass())) { Attachment att = (Attachment)obj; if (att.getObject() == null) { http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java ---------------------------------------------------------------------- diff --git a/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java b/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java index f0b0044..277cd13 100644 --- a/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java +++ b/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java @@ -19,7 +19,6 @@ package org.apache.cxf.endpoint.dynamic; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; @@ -32,6 +31,7 @@ import java.net.URISyntaxException; import java.net.URL; import java.net.URLClassLoader; import java.net.URLDecoder; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -287,7 +287,7 @@ public class DynamicClientFactory { static class DynamicClientImpl extends ClientImpl implements AutoCloseable { final ClassLoader cl; final ClassLoader orig; - DynamicClientImpl(Bus bus, Service svc, QName port, + DynamicClientImpl(Bus bus, Service svc, QName port, EndpointImplFactory endpointImplFactory, ClassLoader l) { super(bus, svc, port, endpointImplFactory); @@ -302,7 +302,7 @@ public class DynamicClientFactory { } } } - + public Client createClient(String wsdlUrl, QName service, ClassLoader classLoader, QName port, List<String> bindingFiles) { @@ -553,7 +553,7 @@ public class DynamicClientFactory { continue; } if (key.startsWith("file:")) { - in = new FileInputStream(new File(new URI(key))); + in = Files.newInputStream(new File(new URI(key)).toPath()); } else { in = new URL(key).openStream(); } @@ -799,7 +799,7 @@ public class DynamicClientFactory { if (systemId != null) { File file = new File(baseURI, systemId); if (file.exists()) { - return new InputSource(new FileInputStream(file)); + return new InputSource(Files.newInputStream(file.toPath())); } else { return new InputSource(systemId); } http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java ---------------------------------------------------------------------- diff --git a/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java b/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java index 05bb683..e346990 100644 --- a/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java +++ b/rt/management/src/main/java/org/apache/cxf/management/persistence/FilesystemExchangeDataDAO.java @@ -19,8 +19,9 @@ package org.apache.cxf.management.persistence; import java.io.File; -import java.io.FileOutputStream; +import java.io.OutputStream; import java.io.StringWriter; +import java.nio.file.Files; import java.util.logging.Level; import java.util.logging.Logger; @@ -116,7 +117,7 @@ public class FilesystemExchangeDataDAO implements ExchangeDataDAO { } } - try (FileOutputStream fileOutputStream = new FileOutputStream(file)) { + try (OutputStream fileOutputStream = Files.newOutputStream(file.toPath())) { fileOutputStream.write(stringWriter.getBuffer().toString().getBytes()); } http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/rt/transports/http/src/main/java/org/apache/cxf/transport/https/httpclient/PublicSuffixMatcherLoader.java ---------------------------------------------------------------------- diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/https/httpclient/PublicSuffixMatcherLoader.java b/rt/transports/http/src/main/java/org/apache/cxf/transport/https/httpclient/PublicSuffixMatcherLoader.java index 86640ee..dc2f7bc 100644 --- a/rt/transports/http/src/main/java/org/apache/cxf/transport/https/httpclient/PublicSuffixMatcherLoader.java +++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/https/httpclient/PublicSuffixMatcherLoader.java @@ -26,12 +26,12 @@ package org.apache.cxf.transport.https.httpclient; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.Arrays; import java.util.logging.Level; import java.util.logging.Logger; @@ -71,7 +71,7 @@ public final class PublicSuffixMatcherLoader { if (file == null) { throw new IllegalArgumentException("File is null"); } - try (InputStream in = new FileInputStream(file)) { + try (InputStream in = Files.newInputStream(file.toPath())) { return load(in); } } http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/repo/file/FileCertificateRepo.java ---------------------------------------------------------------------- diff --git a/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/repo/file/FileCertificateRepo.java b/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/repo/file/FileCertificateRepo.java index 3af3514..9196d61 100644 --- a/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/repo/file/FileCertificateRepo.java +++ b/services/xkms/xkms-x509-handlers/src/main/java/org/apache/cxf/xkms/x509/repo/file/FileCertificateRepo.java @@ -20,12 +20,13 @@ package org.apache.cxf.xkms.x509.repo.file; import java.io.BufferedOutputStream; import java.io.File; -import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.math.BigInteger; import java.net.URISyntaxException; +import java.nio.file.Files; import java.security.cert.CRLException; import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; @@ -87,8 +88,8 @@ public class FileCertificateRepo implements CertificateRepo { File certFile = new File(storageDir + "/" + CRLS_PATH, path); certFile.getParentFile().mkdirs(); - try (FileOutputStream fos = new FileOutputStream(certFile); - BufferedOutputStream bos = new BufferedOutputStream(fos)) { + try (OutputStream os = Files.newOutputStream(certFile.toPath()); + BufferedOutputStream bos = new BufferedOutputStream(os)) { bos.write(crl.getEncoded()); bos.close(); } @@ -110,8 +111,8 @@ public class FileCertificateRepo implements CertificateRepo { File certFile = new File(storageDir + "/" + category, getCertPath(cert, id)); certFile.getParentFile().mkdirs(); - try (FileOutputStream fos = new FileOutputStream(certFile); - BufferedOutputStream bos = new BufferedOutputStream(fos)) { + try (OutputStream os = Files.newOutputStream(certFile.toPath()); + BufferedOutputStream bos = new BufferedOutputStream(os)) { bos.write(cert.getEncoded()); bos.close(); } @@ -178,14 +179,14 @@ public class FileCertificateRepo implements CertificateRepo { public X509Certificate readCertificate(File certFile) throws CertificateException, FileNotFoundException, IOException { - try (FileInputStream fis = new FileInputStream(certFile)) { - return (X509Certificate)certFactory.generateCertificate(fis); + try (InputStream is = Files.newInputStream(certFile.toPath())) { + return (X509Certificate)certFactory.generateCertificate(is); } } public X509CRL readCRL(File crlFile) throws FileNotFoundException, CRLException, IOException { - try (FileInputStream fis = new FileInputStream(crlFile)) { - return (X509CRL)certFactory.generateCRL(fis); + try (InputStream is = Files.newInputStream(crlFile.toPath())) { + return (X509CRL)certFactory.generateCRL(is); } } @@ -272,7 +273,8 @@ public class FileCertificateRepo implements CertificateRepo { certFile.getAbsolutePath())); return null; } - return (X509Certificate)certFactory.generateCertificate(new FileInputStream(certFile)); + InputStream input = Files.newInputStream(certFile.toPath()); + return (X509Certificate)certFactory.generateCertificate(input); } catch (Exception e) { LOG.warn(String.format("Cannot load certificate by endpoint: %s. Error: %s", endpoint, e.getMessage()), e); http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java ---------------------------------------------------------------------- diff --git a/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java b/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java index 7bdb6cd..6996432 100644 --- a/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java +++ b/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java @@ -21,14 +21,16 @@ package org.apache.cxf.testutil.common; import java.io.File; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.io.PrintStream; import java.lang.reflect.Constructor; import java.net.URISyntaxException; import java.net.URL; import java.net.URLClassLoader; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -282,10 +284,10 @@ public class ServerLauncher { public void run() { String outputDir = System.getProperty("server.output.dir", "target/surefire-reports/"); - FileOutputStream fos = null; + OutputStream os = null; try { try { - fos = new FileOutputStream(outputDir + className + ".out"); + os = Files.newOutputStream(Paths.get(outputDir + className + ".out")); } catch (FileNotFoundException fex) { outputDir = System.getProperty("basedir"); if (outputDir == null) { @@ -296,7 +298,7 @@ public class ServerLauncher { File file = new File(outputDir); file.mkdirs(); - fos = new FileOutputStream(outputDir + className + ".out"); + os = Files.newOutputStream(Paths.get(outputDir + className + ".out")); } } catch (IOException ex) { if (!ex.getMessage().contains("Stream closed")) { @@ -304,7 +306,7 @@ public class ServerLauncher { } } - try (PrintStream ps = new PrintStream(fos)) { + try (PrintStream ps = new PrintStream(os)) { boolean running = true; StringBuilder serverOutput = new StringBuilder(); for (int ch = in.read(); ch != -1; ch = in.read()) { http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java ---------------------------------------------------------------------- diff --git a/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java b/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java index 7c08663..503c094 100644 --- a/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java +++ b/tools/common/src/main/java/org/apache/cxf/tools/common/ClassUtils.java @@ -20,9 +20,10 @@ package org.apache.cxf.tools.common; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.file.Files; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; @@ -131,8 +132,8 @@ public class ClassUtils { .substring(0, to.getCanonicalPath().lastIndexOf(File.separator)); File dirFile = new File(dir); dirFile.mkdirs(); - try (FileInputStream input = new FileInputStream(from); - FileOutputStream output = new FileOutputStream(to)) { + try (InputStream input = Files.newInputStream(from.toPath()); + OutputStream output = Files.newOutputStream(to.toPath())) { byte[] b = new byte[1024 * 3]; int len = 0; while (len != -1) { http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java ---------------------------------------------------------------------- diff --git a/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java b/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java index cb21444..7a8053f 100644 --- a/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java +++ b/tools/common/src/main/java/org/apache/cxf/tools/util/JAXBUtils.java @@ -20,7 +20,8 @@ package org.apache.cxf.tools.util; import java.io.File; -import java.io.FileOutputStream; +import java.io.OutputStream; +import java.nio.file.Files; import java.util.List; import javax.xml.XMLConstants; @@ -127,17 +128,17 @@ public final class JAXBUtils { schemaBindings.appendChild(pkgElement); rootElement.appendChild(annoElement); File tmpFile = null; - FileOutputStream fout = null; + OutputStream out = null; try { tmpFile = FileUtils.createTempFile("customzied", ".xsd"); - fout = new FileOutputStream(tmpFile); - StaxUtils.writeTo(rootElement, fout); + out = Files.newOutputStream(tmpFile.toPath()); + StaxUtils.writeTo(rootElement, out); } catch (Exception e) { e.printStackTrace(); } finally { - if (fout != null) { + if (out != null) { try { - fout.close(); + out.close(); } catch (Exception e) { e.printStackTrace(); } http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/tools/common/src/main/java/org/apache/cxf/tools/util/OutputStreamCreator.java ---------------------------------------------------------------------- diff --git a/tools/common/src/main/java/org/apache/cxf/tools/util/OutputStreamCreator.java b/tools/common/src/main/java/org/apache/cxf/tools/util/OutputStreamCreator.java index 5c4253d..28a966b 100644 --- a/tools/common/src/main/java/org/apache/cxf/tools/util/OutputStreamCreator.java +++ b/tools/common/src/main/java/org/apache/cxf/tools/util/OutputStreamCreator.java @@ -20,9 +20,9 @@ package org.apache.cxf.tools.util; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.nio.file.Files; /** * @@ -30,6 +30,6 @@ import java.io.OutputStream; public class OutputStreamCreator { public OutputStream createOutputStream(File file) throws IOException { - return new FileOutputStream(file); + return Files.newOutputStream(file.toPath()); } } http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/tools/common/src/main/java/org/apache/cxf/tools/util/ToolsStaxUtils.java ---------------------------------------------------------------------- diff --git a/tools/common/src/main/java/org/apache/cxf/tools/util/ToolsStaxUtils.java b/tools/common/src/main/java/org/apache/cxf/tools/util/ToolsStaxUtils.java index 3d6f002..db9ae71 100644 --- a/tools/common/src/main/java/org/apache/cxf/tools/util/ToolsStaxUtils.java +++ b/tools/common/src/main/java/org/apache/cxf/tools/util/ToolsStaxUtils.java @@ -21,8 +21,8 @@ package org.apache.cxf.tools.util; import java.io.BufferedInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.InputStream; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -45,7 +45,7 @@ public final class ToolsStaxUtils { List<Tag> tags = new ArrayList<>(); List<String> ignoreEmptyTags = Arrays.asList(new String[]{"sequence"}); - try (InputStream is = new BufferedInputStream(new FileInputStream(source))) { + try (InputStream is = new BufferedInputStream(Files.newInputStream(source.toPath()))) { XMLStreamReader reader = StaxUtils.createXMLStreamReader(is); Tag newTag = null; int count = 0; @@ -104,14 +104,14 @@ public final class ToolsStaxUtils { } public static Tag getTagTree(final File source, final List<String> ignoreAttr) throws Exception { - try (InputStream is = new BufferedInputStream(new FileInputStream(source))) { + try (InputStream is = new BufferedInputStream(Files.newInputStream(source.toPath()))) { return getTagTree(is, ignoreAttr, null); } } public static Tag getTagTree(final File source, final List<String> ignoreAttr, Map<QName, Set<String>> types) throws Exception { - try (InputStream is = new BufferedInputStream(new FileInputStream(source))) { + try (InputStream is = new BufferedInputStream(Files.newInputStream(source.toPath()))) { return getTagTree(is, ignoreAttr, types); } } http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaFactory.java ---------------------------------------------------------------------- diff --git a/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaFactory.java b/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaFactory.java index 384cf72..68f10e5 100644 --- a/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaFactory.java +++ b/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/SchemaFactory.java @@ -20,8 +20,10 @@ package org.apache.cxf.tools.corba.common; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Properties; import javax.wsdl.WSDLException; @@ -126,9 +128,8 @@ public abstract class SchemaFactory { if (propFileName != null) { try { Properties properties = new Properties(); - File propFile = new File(propFileName); - try (FileInputStream fis = new FileInputStream(propFile)) { - properties.load(fis); + try (InputStream is = Files.newInputStream(Paths.get(propFileName))) { + properties.load(is); } factoryImplName = properties.getProperty(PROPERTY_NAME); http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaFactory.java ---------------------------------------------------------------------- diff --git a/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaFactory.java b/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaFactory.java index 04737a1..b70fd97 100644 --- a/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaFactory.java +++ b/tools/corba/src/main/java/org/apache/cxf/tools/corba/common/WSDLCorbaFactory.java @@ -20,8 +20,10 @@ package org.apache.cxf.tools.corba.common; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Properties; import javax.wsdl.Definition; @@ -138,9 +140,8 @@ public abstract class WSDLCorbaFactory { if (propFileName != null) { try { Properties properties = new Properties(); - File propFile = new File(propFileName); - try (FileInputStream fis = new FileInputStream(propFile)) { - properties.load(fis); + try (InputStream is = Files.newInputStream(Paths.get(propFileName))) { + properties.load(is); } factoryImplName = properties.getProperty(PROPERTY_NAME); http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/tools/corba/src/main/java/org/apache/cxf/tools/corba/utils/FileOutputStreamFactory.java ---------------------------------------------------------------------- diff --git a/tools/corba/src/main/java/org/apache/cxf/tools/corba/utils/FileOutputStreamFactory.java b/tools/corba/src/main/java/org/apache/cxf/tools/corba/utils/FileOutputStreamFactory.java index bd343a9..24d90a0 100644 --- a/tools/corba/src/main/java/org/apache/cxf/tools/corba/utils/FileOutputStreamFactory.java +++ b/tools/corba/src/main/java/org/apache/cxf/tools/corba/utils/FileOutputStreamFactory.java @@ -21,9 +21,10 @@ package org.apache.cxf.tools.corba.utils; import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -152,7 +153,7 @@ public class FileOutputStreamFactory implements OutputStreamFactory { addFileName(packageDirName + name); - return new FileOutputStream(dname + name); + return Files.newOutputStream(Paths.get(dname + name)); } @@ -166,7 +167,7 @@ public class FileOutputStreamFactory implements OutputStreamFactory { dname = dirName + name; } - return new FileOutputStream(dname); + return Files.newOutputStream(Paths.get(dname)); } http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java ---------------------------------------------------------------------- diff --git a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java index e0ce6bf..266822b 100644 --- a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java +++ b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2js/processor/JavaToJSProcessor.java @@ -22,10 +22,11 @@ package org.apache.cxf.tools.java2js.processor; import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.io.OutputStreamWriter; import java.nio.charset.Charset; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -84,12 +85,12 @@ public class JavaToJSProcessor implements Processor { Collection<SchemaInfo> schemata = serviceInfo.getSchemas(); BufferedWriter writer = null; try { - FileOutputStream fileOutputStream = new FileOutputStream(jsFile); + OutputStream outputStream = Files.newOutputStream(jsFile.toPath()); if (null != context.get(ToolConstants.CFG_JAVASCRIPT_UTILS)) { - JavascriptGetInterceptor.writeUtilsToResponseStream(JavaToJSProcessor.class, fileOutputStream); + JavascriptGetInterceptor.writeUtilsToResponseStream(JavaToJSProcessor.class, outputStream); } - OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, UTF8); + OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream, UTF8); writer = new BufferedWriter(outputStreamWriter); for (SchemaInfo schema : schemata) { http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java ---------------------------------------------------------------------- diff --git a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java index e0ffec4..78a6090 100644 --- a/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java +++ b/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/generator/wsdl11/WSDL11Generator.java @@ -22,11 +22,11 @@ package org.apache.cxf.tools.java2wsdl.generator.wsdl11; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.Writer; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -96,7 +96,7 @@ public class WSDL11Generator extends AbstractGenerator<Definition> { } else { wsdlFile = new File(outputdir, wsdlDef.getQName().getLocalPart() + ".wsdl"); } - try (OutputStream wsdlOs = new BufferedOutputStream(new FileOutputStream(wsdlFile))) { + try (OutputStream wsdlOs = new BufferedOutputStream(Files.newOutputStream(wsdlFile.toPath()))) { wsdlWriter.writeWSDL(wsdlDef, wsdlOs); } } http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxb/CustomizationParser.java ---------------------------------------------------------------------- diff --git a/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxb/CustomizationParser.java b/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxb/CustomizationParser.java index a07b511..e51d102 100644 --- a/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxb/CustomizationParser.java +++ b/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxb/CustomizationParser.java @@ -19,8 +19,8 @@ package org.apache.cxf.tools.wadlto.jaxb; import java.io.File; -import java.io.FileOutputStream; import java.net.URL; +import java.nio.file.Files; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -154,7 +154,7 @@ public final class CustomizationParser { InputSource result = null; ele.setAttribute("schemaLocation", schemaLoc); File tmpFile = FileUtils.createTempFile("jaxbbinding", ".xml"); - StaxUtils.writeTo(ele, new FileOutputStream(tmpFile)); + StaxUtils.writeTo(ele, Files.newOutputStream(tmpFile.toPath())); result = new InputSource(URIParserUtil.getAbsoluteURI(tmpFile.getAbsolutePath())); tmpFile.deleteOnExit(); return result; http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java ---------------------------------------------------------------------- diff --git a/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java b/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java index df31eb8..a2ec0ea 100644 --- a/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java +++ b/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java @@ -21,7 +21,6 @@ package org.apache.cxf.tools.wadlto.jaxrs; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -32,6 +31,7 @@ import java.io.Writer; import java.net.URI; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -1718,7 +1718,7 @@ public class SourceGenerator { try { file.createNewFile(); - try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), + try (Writer writer = new OutputStreamWriter(Files.newOutputStream(file.toPath()), encoding == null ? StandardCharsets.UTF_8.name() : encoding)) { writer.write(content); writer.flush(); http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java ---------------------------------------------------------------------- diff --git a/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java b/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java index 0b18dad..92f89b3 100644 --- a/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java +++ b/tools/wsdlto/core/src/main/java/org/apache/cxf/tools/wsdlto/WSDLToJavaContainer.java @@ -23,8 +23,6 @@ import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -33,6 +31,7 @@ import java.io.Writer; import java.net.URI; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -356,7 +355,7 @@ public class WSDLToJavaContainer extends AbstractCXFToolContainer { (String)context.get(ToolConstants.CFG_CLIENT_JAR)); JarOutputStream jarout = null; try { - jarout = new JarOutputStream(new FileOutputStream(clientJarFile), new Manifest()); + jarout = new JarOutputStream(Files.newOutputStream(clientJarFile.toPath()), new Manifest()); createClientJar(tmpDir, jarout); jarout.close(); } catch (Exception e) { @@ -392,7 +391,7 @@ public class WSDLToJavaContainer extends AbstractCXFToolContainer { JarEntry entry = new JarEntry(name); entry.setTime(file.lastModified()); jarout.putNextEntry(entry); - InputStream input = new BufferedInputStream(new FileInputStream(file)); + InputStream input = new BufferedInputStream(Files.newInputStream(file.toPath())); IOUtils.copy(input, jarout); input.close(); jarout.closeEntry(); @@ -831,7 +830,7 @@ public class WSDLToJavaContainer extends AbstractCXFToolContainer { } //change the import location in wsdl file - OutputStream wsdloutput = new BufferedOutputStream(new FileOutputStream(wsdlFile)); + OutputStream wsdloutput = new BufferedOutputStream(Files.newOutputStream(wsdlFile.toPath())); WSDLWriter wsdlWriter = WSDLFactory.newInstance().newWSDLWriter(); LoadingByteArrayOutputStream bout = new LoadingByteArrayOutputStream(); wsdlWriter.writeWSDL(def, bout); @@ -849,7 +848,7 @@ public class WSDLToJavaContainer extends AbstractCXFToolContainer { for (Definition importDef : defs) { File importWsdlFile = new File(outputdir, importWSDLMap.get(importDef.getTargetNamespace())); - OutputStream wsdlOs = new BufferedOutputStream(new FileOutputStream(importWsdlFile)); + OutputStream wsdlOs = new BufferedOutputStream(Files.newOutputStream(importWsdlFile.toPath())); bout = new LoadingByteArrayOutputStream(); wsdlWriter.writeWSDL(importDef, bout); Element importEle = StaxUtils.read(bout.createInputStream()).getDocumentElement(); http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java ---------------------------------------------------------------------- diff --git a/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java b/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java index 50045ce..19e4fe5 100644 --- a/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java +++ b/tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java @@ -18,8 +18,6 @@ */ package org.apache.cxf.tools.wsdlto.databinding.jaxb; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.StringReader; @@ -29,6 +27,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.net.URI; import java.net.URL; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -598,7 +597,7 @@ public class JAXBDataBinding implements DataBindingProfile { InputSource result = null; ele.setAttributeNS(null, "schemaLocation", schemaLoc); File tmpFile = FileUtils.createTempFile("jaxbbinding", ".xml"); - StaxUtils.writeTo(ele, new FileOutputStream(tmpFile)); + StaxUtils.writeTo(ele, Files.newOutputStream(tmpFile.toPath())); result = new InputSource(URIParserUtil.getAbsoluteURI(tmpFile.getAbsolutePath())); tmpFile.deleteOnExit(); return result; @@ -682,7 +681,7 @@ public class JAXBDataBinding implements DataBindingProfile { InputStream in = null; try { if (key.startsWith("file:")) { - in = new FileInputStream(new File(new URI(key))); + in = Files.newInputStream(new File(new URI(key)).toPath()); } else { in = new URL(key).openStream(); } http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java ---------------------------------------------------------------------- diff --git a/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java b/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java index 91ff160..fb09b46 100644 --- a/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java +++ b/tools/wsdlto/frontend/javascript/src/main/java/org/apache/cxf/tools/wsdlto/javascript/WSDLToJavaScriptProcessor.java @@ -23,10 +23,11 @@ package org.apache.cxf.tools.wsdlto.javascript; import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.io.OutputStreamWriter; import java.nio.charset.Charset; +import java.nio.file.Files; import java.util.Map; import java.util.logging.Logger; @@ -71,13 +72,13 @@ public class WSDLToJavaScriptProcessor extends WSDLToProcessor { BufferedWriter writer = null; try { - FileOutputStream fileOutputStream = new FileOutputStream(jsFile); + OutputStream outputStream = Files.newOutputStream(jsFile.toPath()); if (null != context.get(ToolConstants.CFG_JAVASCRIPT_UTILS)) { JavascriptGetInterceptor.writeUtilsToResponseStream(WSDLToJavaScriptProcessor.class, - fileOutputStream); + outputStream); } - OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, UTF8); + OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream, UTF8); writer = new BufferedWriter(outputStreamWriter); XmlSchemaCollection collection = serviceInfo.getXmlSchemaCollection().getXmlSchemaCollection(); http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java ---------------------------------------------------------------------- diff --git a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java index 51edf88..951859d 100644 --- a/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java +++ b/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java @@ -19,11 +19,11 @@ package org.apache.cxf.tools.wsdlto.frontend.jaxws.customization; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; +import java.nio.file.Files; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -591,7 +591,7 @@ public final class CustomizationParser { InputSource result = null; ele.setAttributeNS(null, "schemaLocation", schemaLoc); File tmpFile = FileUtils.createTempFile("jaxbbinding", ".xml"); - StaxUtils.writeTo(ele, new FileOutputStream(tmpFile)); + StaxUtils.writeTo(ele, Files.newOutputStream(tmpFile.toPath())); result = new InputSource(URIParserUtil.getAbsoluteURI(tmpFile.getAbsolutePath())); tmpFile.deleteOnExit(); return result; http://git-wip-us.apache.org/repos/asf/cxf/blob/f3304a89/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessor.java ---------------------------------------------------------------------- diff --git a/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessor.java b/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessor.java index 508eb10..ecf7274 100644 --- a/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessor.java +++ b/tools/wsdlto/misc/src/main/java/org/apache/cxf/tools/misc/processor/XSDToWSDLProcessor.java @@ -19,11 +19,12 @@ package org.apache.cxf.tools.misc.processor; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.Writer; import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.logging.Logger; import javax.wsdl.Definition; @@ -102,7 +103,7 @@ public class XSDToWSDLProcessor implements Processor { in = new URL(xsdUrl).openStream(); } catch (Exception m) { try { - in = new FileInputStream(xsdUrl); + in = Files.newInputStream(Paths.get(xsdUrl)); } catch (IOException ioe) { Message msg = new Message("FAIL_TO_OPEN_XSD_FILE", LOG, xsdUrl); throw new ToolException(msg, ioe);