| @@ -25,6 +25,9 @@ Other changes: | |||||
| * added "regexp" attribute to <linecontainsregexp> | * added "regexp" attribute to <linecontainsregexp> | ||||
| Bugzilla Report 60968 | Bugzilla Report 60968 | ||||
| * reduced GC pressure by replacing all usage of FileInputStream and | |||||
| FileOutputStream. | |||||
| Changes from Ant 1.10.0 TO Ant 1.10.1 | Changes from Ant 1.10.0 TO Ant 1.10.1 | ||||
| ===================================== | ===================================== | ||||
| @@ -20,12 +20,12 @@ package org.apache.tools.ant; | |||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| import java.io.Closeable; | import java.io.Closeable; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.lang.reflect.Constructor; | import java.lang.reflect.Constructor; | ||||
| import java.net.MalformedURLException; | import java.net.MalformedURLException; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.nio.file.Files; | |||||
| import java.security.CodeSource; | import java.security.CodeSource; | ||||
| import java.security.ProtectionDomain; | import java.security.ProtectionDomain; | ||||
| import java.security.cert.Certificate; | import java.security.cert.Certificate; | ||||
| @@ -787,7 +787,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo | |||||
| if (jarFile == null && file.isDirectory()) { | if (jarFile == null && file.isDirectory()) { | ||||
| final File resource = new File(file, resourceName); | final File resource = new File(file, resourceName); | ||||
| if (resource.exists()) { | if (resource.exists()) { | ||||
| return new FileInputStream(resource); | |||||
| return Files.newInputStream(resource.toPath()); | |||||
| } | } | ||||
| } else { | } else { | ||||
| if (jarFile == null) { | if (jarFile == null) { | ||||
| @@ -1579,7 +1579,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener, Clo | |||||
| } | } | ||||
| private static boolean readFully(final File f, final byte[] b) throws IOException { | private static boolean readFully(final File f, final byte[] b) throws IOException { | ||||
| try (FileInputStream fis = new FileInputStream(f)) { | |||||
| try (InputStream fis = Files.newInputStream(f.toPath())) { | |||||
| final int len = b.length; | final int len = b.length; | ||||
| int count = 0, x = 0; | int count = 0, x = 0; | ||||
| while (count != len) { | while (count != len) { | ||||
| @@ -18,15 +18,15 @@ | |||||
| package org.apache.tools.ant; | package org.apache.tools.ant; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.FilenameFilter; | import java.io.FilenameFilter; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | |||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.lang.reflect.InvocationTargetException; | import java.lang.reflect.InvocationTargetException; | ||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Calendar; | import java.util.Calendar; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| @@ -576,12 +576,12 @@ public final class Diagnostics { | |||||
| //create the file | //create the file | ||||
| long now = System.currentTimeMillis(); | long now = System.currentTimeMillis(); | ||||
| File tempFile = null; | File tempFile = null; | ||||
| FileOutputStream fileout = null; | |||||
| FileInputStream filein = null; | |||||
| OutputStream fileout = null; | |||||
| InputStream filein = null; | |||||
| try { | try { | ||||
| tempFile = File.createTempFile("diag", "txt", tempDirectory); | tempFile = File.createTempFile("diag", "txt", tempDirectory); | ||||
| //do some writing to it | //do some writing to it | ||||
| fileout = new FileOutputStream(tempFile); | |||||
| fileout = Files.newOutputStream(tempFile.toPath()); | |||||
| byte[] buffer = new byte[KILOBYTE]; | byte[] buffer = new byte[KILOBYTE]; | ||||
| for (int i = 0; i < TEST_FILE_SIZE; i++) { | for (int i = 0; i < TEST_FILE_SIZE; i++) { | ||||
| fileout.write(buffer); | fileout.write(buffer); | ||||
| @@ -591,7 +591,7 @@ public final class Diagnostics { | |||||
| // read to make sure the file has been written completely | // read to make sure the file has been written completely | ||||
| Thread.sleep(1000); | Thread.sleep(1000); | ||||
| filein = new FileInputStream(tempFile); | |||||
| filein = Files.newInputStream(tempFile.toPath()); | |||||
| int total = 0; | int total = 0; | ||||
| int read = 0; | int read = 0; | ||||
| while ((read = filein.read(buffer, 0, KILOBYTE)) > 0) { | while ((read = filein.read(buffer, 0, KILOBYTE)) > 0) { | ||||
| @@ -19,11 +19,11 @@ | |||||
| package org.apache.tools.ant; | package org.apache.tools.ant; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.nio.file.Files; | |||||
| import java.nio.file.Paths; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Arrays; | import java.util.Arrays; | ||||
| import java.util.Collections; | import java.util.Collections; | ||||
| @@ -355,10 +355,10 @@ public class Main implements AntMain { | |||||
| try { | try { | ||||
| final File logFile = new File(args[i + 1]); | final File logFile = new File(args[i + 1]); | ||||
| i++; | i++; | ||||
| // life-cycle of FileOutputStream is controlled by | |||||
| // life-cycle of OutputStream is controlled by | |||||
| // logTo which becomes "out" and is closed in | // logTo which becomes "out" and is closed in | ||||
| // handleLogfile | // handleLogfile | ||||
| logTo = new PrintStream(new FileOutputStream(logFile)); //NOSONAR | |||||
| logTo = new PrintStream(Files.newOutputStream(logFile.toPath())); //NOSONAR | |||||
| isLogFileUsed = true; | isLogFileUsed = true; | ||||
| } catch (final IOException ioe) { | } catch (final IOException ioe) { | ||||
| final String msg = "Cannot write on the specified log file. " | final String msg = "Cannot write on the specified log file. " | ||||
| @@ -656,9 +656,9 @@ public class Main implements AntMain { | |||||
| private void loadPropertyFiles() { | private void loadPropertyFiles() { | ||||
| for (final String filename : propertyFiles) { | for (final String filename : propertyFiles) { | ||||
| final Properties props = new Properties(); | final Properties props = new Properties(); | ||||
| FileInputStream fis = null; | |||||
| InputStream fis = null; | |||||
| try { | try { | ||||
| fis = new FileInputStream(filename); | |||||
| fis = Files.newInputStream(Paths.get(filename)); | |||||
| props.load(fis); | props.load(fis); | ||||
| } catch (final IOException e) { | } catch (final IOException e) { | ||||
| System.out.println("Could not load property file " | System.out.println("Could not load property file " | ||||
| @@ -17,12 +17,13 @@ | |||||
| */ | */ | ||||
| package org.apache.tools.ant; | package org.apache.tools.ant; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.io.Writer; | import java.io.Writer; | ||||
| import java.nio.file.Files; | |||||
| import java.nio.file.Paths; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Stack; | import java.util.Stack; | ||||
| @@ -185,7 +186,7 @@ public class XmlLogger implements BuildLogger { | |||||
| // up everything | // up everything | ||||
| OutputStream stream = outStream; | OutputStream stream = outStream; | ||||
| if (stream == null) { | if (stream == null) { | ||||
| stream = new FileOutputStream(outFilename); | |||||
| stream = Files.newOutputStream(Paths.get(outFilename)); | |||||
| } | } | ||||
| out = new OutputStreamWriter(stream, "UTF8"); | out = new OutputStreamWriter(stream, "UTF8"); | ||||
| out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); | out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); | ||||
| @@ -18,13 +18,13 @@ | |||||
| package org.apache.tools.ant.helper; | package org.apache.tools.ant.helper; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.UnsupportedEncodingException; | import java.io.UnsupportedEncodingException; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.net.URLConnection; | import java.net.URLConnection; | ||||
| import java.nio.file.Files; | |||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -247,7 +247,7 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
| String uri = null; | String uri = null; | ||||
| if (buildFile != null) { | if (buildFile != null) { | ||||
| uri = FILE_UTILS.toURI(buildFile.getAbsolutePath()); | uri = FILE_UTILS.toURI(buildFile.getAbsolutePath()); | ||||
| inputStream = new FileInputStream(buildFile); | |||||
| inputStream = Files.newInputStream(buildFile.toPath()); | |||||
| } else { | } else { | ||||
| uri = url.toString(); | uri = url.toString(); | ||||
| int pling = -1; | int pling = -1; | ||||
| @@ -538,10 +538,10 @@ public class ProjectHelper2 extends ProjectHelper { | |||||
| } | } | ||||
| context.getProject().log("file=" + file, Project.MSG_DEBUG); | context.getProject().log("file=" + file, Project.MSG_DEBUG); | ||||
| try { | try { | ||||
| InputSource inputSource = new InputSource(new FileInputStream(file)); | |||||
| InputSource inputSource = new InputSource(Files.newInputStream(file.toPath())); | |||||
| inputSource.setSystemId(FILE_UTILS.toURI(file.getAbsolutePath())); | inputSource.setSystemId(FILE_UTILS.toURI(file.getAbsolutePath())); | ||||
| return inputSource; | return inputSource; | ||||
| } catch (FileNotFoundException fne) { | |||||
| } catch (IOException fne) { | |||||
| context.getProject().log(file.getAbsolutePath() + " could not be found", | context.getProject().log(file.getAbsolutePath() + " could not be found", | ||||
| Project.MSG_WARN); | Project.MSG_WARN); | ||||
| } | } | ||||
| @@ -18,10 +18,11 @@ | |||||
| package org.apache.tools.ant.helper; | package org.apache.tools.ant.helper; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | |||||
| import java.io.UnsupportedEncodingException; | import java.io.UnsupportedEncodingException; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Locale; | import java.util.Locale; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| @@ -110,7 +111,7 @@ public class ProjectHelperImpl extends ProjectHelper { | |||||
| + "default plugin"); | + "default plugin"); | ||||
| } | } | ||||
| File bFile = (File) source; | File bFile = (File) source; | ||||
| FileInputStream inputStream = null; | |||||
| InputStream inputStream = null; | |||||
| InputSource inputSource = null; | InputSource inputSource = null; | ||||
| this.project = project; | this.project = project; | ||||
| @@ -124,7 +125,7 @@ public class ProjectHelperImpl extends ProjectHelper { | |||||
| parser = new XMLReaderAdapter(JAXPUtils.getXMLReader()); | parser = new XMLReaderAdapter(JAXPUtils.getXMLReader()); | ||||
| } | } | ||||
| String uri = FILE_UTILS.toURI(bFile.getAbsolutePath()); | String uri = FILE_UTILS.toURI(bFile.getAbsolutePath()); | ||||
| inputStream = new FileInputStream(bFile); | |||||
| inputStream = Files.newInputStream(bFile.toPath()); | |||||
| inputSource = new InputSource(inputStream); | inputSource = new InputSource(inputStream); | ||||
| inputSource.setSystemId(uri); | inputSource.setSystemId(uri); | ||||
| project.log("parsing buildfile " + bFile + " with URI = " + uri, Project.MSG_VERBOSE); | project.log("parsing buildfile " + bFile + " with URI = " + uri, Project.MSG_VERBOSE); | ||||
| @@ -302,10 +303,10 @@ public class ProjectHelperImpl extends ProjectHelper { | |||||
| + "' for compliance with other XML tools", Project.MSG_WARN); | + "' for compliance with other XML tools", Project.MSG_WARN); | ||||
| } | } | ||||
| try { | try { | ||||
| InputSource inputSource = new InputSource(new FileInputStream(file)); | |||||
| InputSource inputSource = new InputSource(Files.newInputStream(file.toPath())); | |||||
| inputSource.setSystemId(FILE_UTILS.toURI(file.getAbsolutePath())); | inputSource.setSystemId(FILE_UTILS.toURI(file.getAbsolutePath())); | ||||
| return inputSource; | return inputSource; | ||||
| } catch (FileNotFoundException fne) { | |||||
| } catch (IOException fne) { | |||||
| helperImpl.project.log(file.getAbsolutePath() + " could not be found", | helperImpl.project.log(file.getAbsolutePath() + " could not be found", | ||||
| Project.MSG_WARN); | Project.MSG_WARN); | ||||
| } | } | ||||
| @@ -18,8 +18,9 @@ | |||||
| package org.apache.tools.ant.input; | package org.apache.tools.ant.input; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.nio.file.Files; | |||||
| import java.nio.file.Paths; | |||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| @@ -82,7 +83,7 @@ public class PropertyFileInputHandler implements InputHandler { | |||||
| props = new Properties(); | props = new Properties(); | ||||
| try { | try { | ||||
| props.load(new FileInputStream(propsFile)); | |||||
| props.load(Files.newInputStream(Paths.get(propsFile))); | |||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| throw new BuildException("Couldn't load " + propsFile, e); | throw new BuildException("Couldn't load " + propsFile, e); | ||||
| } | } | ||||
| @@ -17,10 +17,11 @@ | |||||
| */ | */ | ||||
| package org.apache.tools.ant.listener; | package org.apache.tools.ant.listener; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.nio.file.Files; | |||||
| import java.nio.file.Paths; | |||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import org.apache.tools.ant.DefaultLogger; | import org.apache.tools.ant.DefaultLogger; | ||||
| @@ -162,7 +163,7 @@ public class AnsiColorLogger extends DefaultLogger { | |||||
| Properties prop = new Properties(); | Properties prop = new Properties(); | ||||
| if (userColorFile != null) { | if (userColorFile != null) { | ||||
| in = new FileInputStream(userColorFile); | |||||
| in = Files.newInputStream(Paths.get(userColorFile)); | |||||
| } else { | } else { | ||||
| in = getClass().getResourceAsStream(systemColorFile); | in = getClass().getResourceAsStream(systemColorFile); | ||||
| } | } | ||||
| @@ -18,10 +18,11 @@ | |||||
| package org.apache.tools.ant.listener; | package org.apache.tools.ant.listener; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.nio.file.Files; | |||||
| import java.nio.file.Paths; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| @@ -119,7 +120,7 @@ public class MailLogger extends DefaultLogger { | |||||
| if (filename != null) { | if (filename != null) { | ||||
| InputStream is = null; | InputStream is = null; | ||||
| try { | try { | ||||
| is = new FileInputStream(filename); | |||||
| is = Files.newInputStream(Paths.get(filename)); | |||||
| fileProperties.load(is); | fileProperties.load(is); | ||||
| } catch (IOException ioe) { | } catch (IOException ioe) { | ||||
| // ignore because properties file is not required | // ignore because properties file is not required | ||||
| @@ -20,10 +20,10 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.nio.file.Paths; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| @@ -201,8 +201,7 @@ public abstract class AbstractCvsTask extends Task { | |||||
| try { | try { | ||||
| setOutputStream(new PrintStream( | setOutputStream(new PrintStream( | ||||
| new BufferedOutputStream( | new BufferedOutputStream( | ||||
| new FileOutputStream(output | |||||
| .getPath(), | |||||
| FileUtils.newOutputStream(Paths.get(output.getPath()), | |||||
| append)))); | append)))); | ||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| throw new BuildException(e, getLocation()); | throw new BuildException(e, getLocation()); | ||||
| @@ -241,7 +240,7 @@ public abstract class AbstractCvsTask extends Task { | |||||
| try { | try { | ||||
| setErrorStream(new PrintStream( | setErrorStream(new PrintStream( | ||||
| new BufferedOutputStream( | new BufferedOutputStream( | ||||
| new FileOutputStream(error.getPath(), | |||||
| FileUtils.newOutputStream(Paths.get(error.getPath()), | |||||
| append)))); | append)))); | ||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| throw new BuildException(e, getLocation()); | throw new BuildException(e, getLocation()); | ||||
| @@ -19,10 +19,10 @@ | |||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.HashSet; | import java.util.HashSet; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| @@ -206,7 +206,7 @@ public class Ant extends Task { | |||||
| outfile = getProject().resolveFile(output); | outfile = getProject().resolveFile(output); | ||||
| } | } | ||||
| try { | try { | ||||
| out = new PrintStream(new FileOutputStream(outfile)); | |||||
| out = new PrintStream(Files.newOutputStream(outfile.toPath())); | |||||
| DefaultLogger logger = new DefaultLogger(); | DefaultLogger logger = new DefaultLogger(); | ||||
| logger.setMessageOutputLevel(Project.MSG_INFO); | logger.setMessageOutputLevel(Project.MSG_INFO); | ||||
| logger.setOutputPrintStream(out); | logger.setOutputPrintStream(out); | ||||
| @@ -19,12 +19,13 @@ | |||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | |||||
| import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
| import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
| import java.io.UnsupportedEncodingException; | import java.io.UnsupportedEncodingException; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| @@ -85,9 +86,9 @@ public class AntStructure extends Task { | |||||
| PrintWriter out = null; | PrintWriter out = null; | ||||
| try { | try { | ||||
| FileOutputStream fos = null; | |||||
| OutputStream fos = null; | |||||
| try { | try { | ||||
| fos = new FileOutputStream(output); | |||||
| fos = Files.newOutputStream(output.toPath()); | |||||
| out = new PrintWriter(new OutputStreamWriter(fos, "UTF8")); | out = new PrintWriter(new OutputStreamWriter(fos, "UTF8")); | ||||
| } catch (final UnsupportedEncodingException ue) { | } catch (final UnsupportedEncodingException ue) { | ||||
| FileUtils.close(fos); | FileUtils.close(fos); | ||||
| @@ -20,9 +20,10 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.BufferedInputStream; | import java.io.BufferedInputStream; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | |||||
| import java.nio.file.Files; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -60,12 +61,12 @@ public class BUnzip2 extends Unpack { | |||||
| log("Expanding " + srcResource.getName() + " to " | log("Expanding " + srcResource.getName() + " to " | ||||
| + dest.getAbsolutePath()); | + dest.getAbsolutePath()); | ||||
| FileOutputStream out = null; | |||||
| OutputStream out = null; | |||||
| CBZip2InputStream zIn = null; | CBZip2InputStream zIn = null; | ||||
| InputStream fis = null; | InputStream fis = null; | ||||
| BufferedInputStream bis = null; | BufferedInputStream bis = null; | ||||
| try { | try { | ||||
| out = new FileOutputStream(dest); | |||||
| out = Files.newOutputStream(dest.toPath()); | |||||
| fis = srcResource.getInputStream(); | fis = srcResource.getInputStream(); | ||||
| bis = new BufferedInputStream(fis); | bis = new BufferedInputStream(fis); | ||||
| int b = bis.read(); | int b = bis.read(); | ||||
| @@ -20,8 +20,9 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | |||||
| import java.nio.file.Files; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -44,7 +45,7 @@ public class BZip2 extends Pack { | |||||
| CBZip2OutputStream zOut = null; | CBZip2OutputStream zOut = null; | ||||
| try { | try { | ||||
| BufferedOutputStream bos = | BufferedOutputStream bos = | ||||
| new BufferedOutputStream(new FileOutputStream(zipFile)); | |||||
| new BufferedOutputStream(Files.newOutputStream(zipFile.toPath())); | |||||
| bos.write('B'); | bos.write('B'); | ||||
| bos.write('Z'); | bos.write('Z'); | ||||
| zOut = new CBZip2OutputStream(bos); | zOut = new CBZip2OutputStream(bos); | ||||
| @@ -18,9 +18,10 @@ | |||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | |||||
| import java.io.OutputStream; | |||||
| import java.nio.file.Files; | |||||
| import java.util.Properties; | import java.util.Properties; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| @@ -84,10 +85,10 @@ public class BuildNumber | |||||
| String.valueOf(buildNumber + 1)); | String.valueOf(buildNumber + 1)); | ||||
| // Write the properties file back out | // Write the properties file back out | ||||
| FileOutputStream output = null; | |||||
| OutputStream output = null; | |||||
| try { | try { | ||||
| output = new FileOutputStream(myFile); | |||||
| output = Files.newOutputStream(myFile.toPath()); | |||||
| final String header = "Build Number for ANT. Do not edit!"; | final String header = "Build Number for ANT. Do not edit!"; | ||||
| @@ -144,12 +145,12 @@ public class BuildNumber | |||||
| */ | */ | ||||
| private Properties loadProperties() | private Properties loadProperties() | ||||
| throws BuildException { | throws BuildException { | ||||
| FileInputStream input = null; | |||||
| InputStream input = null; | |||||
| try { | try { | ||||
| final Properties properties = new Properties(); | final Properties properties = new Properties(); | ||||
| input = new FileInputStream(myFile); | |||||
| input = Files.newInputStream(myFile.toPath()); | |||||
| properties.load(input); | properties.load(input); | ||||
| return properties; | return properties; | ||||
| } catch (final IOException ioe) { | } catch (final IOException ioe) { | ||||
| @@ -19,10 +19,11 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | |||||
| import java.io.OutputStream; | |||||
| import java.nio.file.Files; | |||||
| import java.security.DigestInputStream; | import java.security.DigestInputStream; | ||||
| import java.security.MessageDigest; | import java.security.MessageDigest; | ||||
| import java.security.NoSuchAlgorithmException; | import java.security.NoSuchAlgorithmException; | ||||
| @@ -471,8 +472,8 @@ public class Checksum extends MatchingTask implements Condition { | |||||
| */ | */ | ||||
| private boolean generateChecksums() throws BuildException { | private boolean generateChecksums() throws BuildException { | ||||
| boolean checksumMatches = true; | boolean checksumMatches = true; | ||||
| FileInputStream fis = null; | |||||
| FileOutputStream fos = null; | |||||
| InputStream fis = null; | |||||
| OutputStream fos = null; | |||||
| byte[] buf = new byte[readBufferSize]; | byte[] buf = new byte[readBufferSize]; | ||||
| try { | try { | ||||
| for (Map.Entry<File, Object> e : includeFileMap.entrySet()) { | for (Map.Entry<File, Object> e : includeFileMap.entrySet()) { | ||||
| @@ -481,7 +482,7 @@ public class Checksum extends MatchingTask implements Condition { | |||||
| if (!isCondition) { | if (!isCondition) { | ||||
| log("Calculating " + algorithm + " checksum for " + src, Project.MSG_VERBOSE); | log("Calculating " + algorithm + " checksum for " + src, Project.MSG_VERBOSE); | ||||
| } | } | ||||
| fis = new FileInputStream(src); | |||||
| fis = Files.newInputStream(src.toPath()); | |||||
| DigestInputStream dis = new DigestInputStream(fis, | DigestInputStream dis = new DigestInputStream(fis, | ||||
| messageDigest); | messageDigest); | ||||
| while (dis.read(buf, 0, readBufferSize) != -1) { | while (dis.read(buf, 0, readBufferSize) != -1) { | ||||
| @@ -523,7 +524,7 @@ public class Checksum extends MatchingTask implements Condition { | |||||
| } | } | ||||
| } else { | } else { | ||||
| File dest = (File) destination; | File dest = (File) destination; | ||||
| fos = new FileOutputStream(dest); | |||||
| fos = Files.newOutputStream(dest.toPath()); | |||||
| fos.write(format.format(new Object[] { | fos.write(format.format(new Object[] { | ||||
| checksum, | checksum, | ||||
| src.getName(), | src.getName(), | ||||
| @@ -19,7 +19,6 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| @@ -27,6 +26,7 @@ import java.io.InputStreamReader; | |||||
| import java.io.Reader; | import java.io.Reader; | ||||
| import java.io.StringReader; | import java.io.StringReader; | ||||
| import java.io.Writer; | import java.io.Writer; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Arrays; | import java.util.Arrays; | ||||
| import java.util.Collections; | import java.util.Collections; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| @@ -139,7 +139,7 @@ public class Concat extends Task implements ResourceCollection { | |||||
| reader = new BufferedReader(new FileReader(file)); | reader = new BufferedReader(new FileReader(file)); | ||||
| } else { | } else { | ||||
| reader = new BufferedReader( | reader = new BufferedReader( | ||||
| new InputStreamReader(new FileInputStream(file), | |||||
| new InputStreamReader(Files.newInputStream(file.toPath()), | |||||
| this.encoding)); | this.encoding)); | ||||
| } | } | ||||
| value = FileUtils.safeReadFully(reader); | value = FileUtils.safeReadFully(reader); | ||||
| @@ -18,7 +18,6 @@ | |||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| @@ -83,7 +82,7 @@ public class EchoXML extends XMLFragment { | |||||
| OutputStream os = null; | OutputStream os = null; | ||||
| try { | try { | ||||
| if (file != null) { | if (file != null) { | ||||
| os = new FileOutputStream(file.getAbsolutePath(), append); | |||||
| os = FileUtils.newOutputStream(file.toPath(), append); | |||||
| } else { | } else { | ||||
| os = new LogOutputStream(this, Project.MSG_INFO); | os = new LogOutputStream(this, Project.MSG_INFO); | ||||
| } | } | ||||
| @@ -20,9 +20,10 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | |||||
| import java.nio.file.Files; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.HashSet; | import java.util.HashSet; | ||||
| @@ -350,9 +351,9 @@ public class Expand extends Task { | |||||
| } else { | } else { | ||||
| byte[] buffer = new byte[BUFFER_SIZE]; | byte[] buffer = new byte[BUFFER_SIZE]; | ||||
| int length = 0; | int length = 0; | ||||
| FileOutputStream fos = null; | |||||
| OutputStream fos = null; | |||||
| try { | try { | ||||
| fos = new FileOutputStream(f); | |||||
| fos = Files.newOutputStream(f.toPath()); | |||||
| while ((length = | while ((length = | ||||
| compressedInputStream.read(buffer)) >= 0) { | compressedInputStream.read(buffer)) >= 0) { | ||||
| @@ -20,11 +20,11 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| import java.io.Reader; | import java.io.Reader; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.NoSuchElementException; | import java.util.NoSuchElementException; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| @@ -421,7 +421,7 @@ public class FixCRLF extends MatchingTask implements ChainableReader { | |||||
| reader = new BufferedReader( | reader = new BufferedReader( | ||||
| ((encoding == null) ? new FileReader(srcFile) | ((encoding == null) ? new FileReader(srcFile) | ||||
| : new InputStreamReader( | : new InputStreamReader( | ||||
| new FileInputStream(srcFile), encoding)), INBUFLEN); | |||||
| Files.newInputStream(srcFile.toPath()), encoding)), INBUFLEN); | |||||
| nextLine(); | nextLine(); | ||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| @@ -18,9 +18,10 @@ | |||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | |||||
| import java.nio.file.Files; | |||||
| import java.util.zip.GZIPInputStream; | import java.util.zip.GZIPInputStream; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| @@ -56,11 +57,11 @@ public class GUnzip extends Unpack { | |||||
| log("Expanding " + srcResource.getName() + " to " | log("Expanding " + srcResource.getName() + " to " | ||||
| + dest.getAbsolutePath()); | + dest.getAbsolutePath()); | ||||
| FileOutputStream out = null; | |||||
| OutputStream out = null; | |||||
| GZIPInputStream zIn = null; | GZIPInputStream zIn = null; | ||||
| InputStream fis = null; | InputStream fis = null; | ||||
| try { | try { | ||||
| out = new FileOutputStream(dest); | |||||
| out = Files.newOutputStream(dest.toPath()); | |||||
| fis = srcResource.getInputStream(); | fis = srcResource.getInputStream(); | ||||
| zIn = new GZIPInputStream(fis); | zIn = new GZIPInputStream(fis); | ||||
| byte[] buffer = new byte[BUFFER_SIZE]; | byte[] buffer = new byte[BUFFER_SIZE]; | ||||
| @@ -18,8 +18,9 @@ | |||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | |||||
| import java.nio.file.Files; | |||||
| import java.util.zip.GZIPOutputStream; | import java.util.zip.GZIPOutputStream; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| @@ -41,7 +42,7 @@ public class GZip extends Pack { | |||||
| protected void pack() { | protected void pack() { | ||||
| GZIPOutputStream zOut = null; | GZIPOutputStream zOut = null; | ||||
| try { | try { | ||||
| zOut = new GZIPOutputStream(new FileOutputStream(zipFile)); | |||||
| zOut = new GZIPOutputStream(Files.newOutputStream(zipFile.toPath())); | |||||
| zipResource(getSrcResource(), zOut); | zipResource(getSrcResource(), zOut); | ||||
| } catch (IOException ioe) { | } catch (IOException ioe) { | ||||
| String msg = "Problem creating gzip " + ioe.getMessage(); | String msg = "Problem creating gzip " + ioe.getMessage(); | ||||
| @@ -20,7 +20,6 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| @@ -28,6 +27,7 @@ import java.io.PrintStream; | |||||
| import java.net.HttpURLConnection; | import java.net.HttpURLConnection; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.net.URLConnection; | import java.net.URLConnection; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.zip.GZIPInputStream; | import java.util.zip.GZIPInputStream; | ||||
| @@ -852,7 +852,7 @@ public class Get extends Task { | |||||
| is = new GZIPInputStream(is); | is = new GZIPInputStream(is); | ||||
| } | } | ||||
| os = new FileOutputStream(dest); | |||||
| os = Files.newOutputStream(dest.toPath()); | |||||
| progress.beginDownload(); | progress.beginDownload(); | ||||
| boolean finished = false; | boolean finished = false; | ||||
| try { | try { | ||||
| @@ -21,7 +21,6 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.ByteArrayInputStream; | import java.io.ByteArrayInputStream; | ||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| @@ -29,6 +28,7 @@ import java.io.OutputStreamWriter; | |||||
| import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
| import java.io.Reader; | import java.io.Reader; | ||||
| import java.io.UnsupportedEncodingException; | import java.io.UnsupportedEncodingException; | ||||
| import java.nio.file.Files; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Collections; | import java.util.Collections; | ||||
| import java.util.Comparator; | import java.util.Comparator; | ||||
| @@ -303,10 +303,10 @@ public class Jar extends Zip { | |||||
| private Manifest getManifest(File manifestFile) { | private Manifest getManifest(File manifestFile) { | ||||
| Manifest newManifest = null; | Manifest newManifest = null; | ||||
| FileInputStream fis = null; | |||||
| InputStream fis = null; | |||||
| InputStreamReader isr = null; | InputStreamReader isr = null; | ||||
| try { | try { | ||||
| fis = new FileInputStream(manifestFile); | |||||
| fis = Files.newInputStream(manifestFile.toPath()); | |||||
| if (manifestEncoding == null) { | if (manifestEncoding == null) { | ||||
| isr = new InputStreamReader(fis); | isr = new InputStreamReader(fis); | ||||
| } else { | } else { | ||||
| @@ -20,9 +20,9 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileFilter; | import java.io.FileFilter; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.nio.file.Files; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Collection; | import java.util.Collection; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| @@ -1471,7 +1471,7 @@ public class Javac extends MatchingTask { | |||||
| continue; | continue; | ||||
| } | } | ||||
| log("Creating empty " + pkgInfoClass); | log("Creating empty " + pkgInfoClass); | ||||
| try (OutputStream os = new FileOutputStream(pkgInfoClass)) { | |||||
| try (OutputStream os = Files.newOutputStream(pkgInfoClass.toPath())) { | |||||
| os.write(PACKAGE_INFO_CLASS_HEADER); | os.write(PACKAGE_INFO_CLASS_HEADER); | ||||
| final byte[] name = pkg.getBytes("UTF-8"); | final byte[] name = pkg.getBytes("UTF-8"); | ||||
| final int length = name.length + /* "/package-info" */ 13; | final int length = name.length + /* "/package-info" */ 13; | ||||
| @@ -20,18 +20,18 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| import java.io.FilenameFilter; | import java.io.FilenameFilter; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| import java.io.OutputStream; | |||||
| import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
| import java.net.MalformedURLException; | import java.net.MalformedURLException; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.nio.file.Files; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.HashSet; | import java.util.HashSet; | ||||
| @@ -2516,7 +2516,7 @@ public class Javadoc extends Task { | |||||
| : FILE_UTILS.getDefaultEncoding(); | : FILE_UTILS.getDefaultEncoding(); | ||||
| // we load the whole file as one String (toc/index files are | // we load the whole file as one String (toc/index files are | ||||
| // generally small, because they only contain frameset declaration): | // generally small, because they only contain frameset declaration): | ||||
| final InputStream fin = new FileInputStream(file); | |||||
| final InputStream fin = Files.newInputStream(file.toPath()); | |||||
| String fileContents; | String fileContents; | ||||
| try { | try { | ||||
| fileContents = | fileContents = | ||||
| @@ -2532,7 +2532,7 @@ public class Javadoc extends Task { | |||||
| // we need to patch the file! | // we need to patch the file! | ||||
| final String patchedFileContents = patchContent(fileContents, fixData); | final String patchedFileContents = patchContent(fileContents, fixData); | ||||
| if (!patchedFileContents.equals(fileContents)) { | if (!patchedFileContents.equals(fileContents)) { | ||||
| final FileOutputStream fos = new FileOutputStream(file); | |||||
| final OutputStream fos = Files.newOutputStream(file.toPath()); | |||||
| try { | try { | ||||
| final OutputStreamWriter w = new OutputStreamWriter(fos, enc); | final OutputStreamWriter w = new OutputStreamWriter(fos, enc); | ||||
| w.write(patchedFileContents); | w.write(patchedFileContents); | ||||
| @@ -19,12 +19,13 @@ | |||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | |||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| import java.io.OutputStream; | |||||
| import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
| import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| @@ -227,10 +228,10 @@ public class ManifestTask extends Task { | |||||
| BuildException error = null; | BuildException error = null; | ||||
| if (manifestFile.exists()) { | if (manifestFile.exists()) { | ||||
| FileInputStream fis = null; | |||||
| InputStream fis = null; | |||||
| InputStreamReader isr = null; | InputStreamReader isr = null; | ||||
| try { | try { | ||||
| fis = new FileInputStream(manifestFile); | |||||
| fis = Files.newInputStream(manifestFile.toPath()); | |||||
| if (encoding == null) { | if (encoding == null) { | ||||
| isr = new InputStreamReader(fis, "UTF-8"); | isr = new InputStreamReader(fis, "UTF-8"); | ||||
| } else { | } else { | ||||
| @@ -276,7 +277,7 @@ public class ManifestTask extends Task { | |||||
| PrintWriter w = null; | PrintWriter w = null; | ||||
| try { | try { | ||||
| FileOutputStream fos = new FileOutputStream(manifestFile); | |||||
| OutputStream fos = Files.newOutputStream(manifestFile.toPath()); | |||||
| OutputStreamWriter osw = new OutputStreamWriter(fos, Manifest.JAR_ENCODING); | OutputStreamWriter osw = new OutputStreamWriter(fos, Manifest.JAR_ENCODING); | ||||
| w = new PrintWriter(osw); | w = new PrintWriter(osw); | ||||
| toWrite.write(w, flattenClassPaths); | toWrite.write(w, flattenClassPaths); | ||||
| @@ -18,10 +18,10 @@ | |||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.nio.file.Files; | |||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -575,9 +575,9 @@ public class Property extends Task { | |||||
| log("Loading " + file.getAbsolutePath(), Project.MSG_VERBOSE); | log("Loading " + file.getAbsolutePath(), Project.MSG_VERBOSE); | ||||
| try { | try { | ||||
| if (file.exists()) { | if (file.exists()) { | ||||
| FileInputStream fis = null; | |||||
| InputStream fis = null; | |||||
| try { | try { | ||||
| fis = new FileInputStream(file); | |||||
| fis = Files.newInputStream(file.toPath()); | |||||
| loadProperties(props, fis, file.getName().endsWith(".xml")); | loadProperties(props, fis, file.getName().endsWith(".xml")); | ||||
| } finally { | } finally { | ||||
| FileUtils.close(fis); | FileUtils.close(fis); | ||||
| @@ -17,9 +17,9 @@ | |||||
| */ | */ | ||||
| package org.apache.tools.ant.taskdefs; | package org.apache.tools.ant.taskdefs; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.nio.file.Paths; | |||||
| import org.apache.tools.ant.BuildEvent; | import org.apache.tools.ant.BuildEvent; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| @@ -27,6 +27,7 @@ import org.apache.tools.ant.BuildLogger; | |||||
| import org.apache.tools.ant.DefaultLogger; | import org.apache.tools.ant.DefaultLogger; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.SubBuildListener; | import org.apache.tools.ant.SubBuildListener; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| import org.apache.tools.ant.util.StringUtils; | import org.apache.tools.ant.util.StringUtils; | ||||
| /** | /** | ||||
| @@ -356,7 +357,7 @@ public class RecorderEntry implements BuildLogger, SubBuildListener { | |||||
| private void openFileImpl(boolean append) throws BuildException { | private void openFileImpl(boolean append) throws BuildException { | ||||
| if (out == null) { | if (out == null) { | ||||
| try { | try { | ||||
| out = new PrintStream(new FileOutputStream(filename, append)); | |||||
| out = new PrintStream(FileUtils.newOutputStream(Paths.get(filename), append)); | |||||
| } catch (IOException ioe) { | } catch (IOException ioe) { | ||||
| throw new BuildException("Problems opening file using a " | throw new BuildException("Problems opening file using a " | ||||
| + "recorder entry", ioe); | + "recorder entry", ioe); | ||||
| @@ -21,8 +21,6 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| @@ -30,6 +28,7 @@ import java.io.OutputStream; | |||||
| import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
| import java.io.Reader; | import java.io.Reader; | ||||
| import java.io.Writer; | import java.io.Writer; | ||||
| import java.nio.file.Files; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Collections; | import java.util.Collections; | ||||
| import java.util.Comparator; | import java.util.Comparator; | ||||
| @@ -369,7 +368,7 @@ public class Replace extends MatchingTask { | |||||
| FileInput(File source) throws IOException { | FileInput(File source) throws IOException { | ||||
| outputBuffer = new StringBuffer(); | outputBuffer = new StringBuffer(); | ||||
| buffer = new char[BUFF_SIZE]; | buffer = new char[BUFF_SIZE]; | ||||
| is = new FileInputStream(source); | |||||
| is = Files.newInputStream(source.toPath()); | |||||
| try { | try { | ||||
| reader = new BufferedReader(encoding != null ? new InputStreamReader(is, encoding) : new InputStreamReader(is)); | reader = new BufferedReader(encoding != null ? new InputStreamReader(is, encoding) : new InputStreamReader(is)); | ||||
| } finally { | } finally { | ||||
| @@ -429,7 +428,7 @@ public class Replace extends MatchingTask { | |||||
| * @throws IOException When the file cannot be read from. | * @throws IOException When the file cannot be read from. | ||||
| */ | */ | ||||
| FileOutput(File out) throws IOException { | FileOutput(File out) throws IOException { | ||||
| os = new FileOutputStream(out); | |||||
| os = Files.newOutputStream(out.toPath()); | |||||
| try { | try { | ||||
| writer = new BufferedWriter(encoding != null ? new OutputStreamWriter(os, encoding) : new OutputStreamWriter(os)); | writer = new BufferedWriter(encoding != null ? new OutputStreamWriter(os, encoding) : new OutputStreamWriter(os)); | ||||
| } finally { | } finally { | ||||
| @@ -20,7 +20,6 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| @@ -651,7 +650,7 @@ public class SQLExec extends JDBCTask { | |||||
| FileProvider fp = | FileProvider fp = | ||||
| output.as(FileProvider.class); | output.as(FileProvider.class); | ||||
| if (fp != null) { | if (fp != null) { | ||||
| os = new FileOutputStream(fp.getFile(), append); | |||||
| os = FileUtils.newOutputStream(fp.getFile().toPath(), append); | |||||
| } else { | } else { | ||||
| if (append) { | if (append) { | ||||
| Appendable a = | Appendable a = | ||||
| @@ -20,12 +20,12 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.lang.reflect.Constructor; | import java.lang.reflect.Constructor; | ||||
| import java.lang.reflect.InvocationTargetException; | import java.lang.reflect.InvocationTargetException; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Collection; | import java.util.Collection; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.HashSet; | import java.util.HashSet; | ||||
| @@ -327,7 +327,7 @@ public class Tar extends MatchingTask { | |||||
| tOut = new TarOutputStream( | tOut = new TarOutputStream( | ||||
| compression.compress( | compression.compress( | ||||
| new BufferedOutputStream( | new BufferedOutputStream( | ||||
| new FileOutputStream(tarFile))), | |||||
| Files.newOutputStream(tarFile.toPath()))), | |||||
| encoding); | encoding); | ||||
| tOut.setDebug(true); | tOut.setDebug(true); | ||||
| if (longFileMode.isTruncateMode()) { | if (longFileMode.isTruncateMode()) { | ||||
| @@ -20,11 +20,11 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.BufferedInputStream; | import java.io.BufferedInputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.lang.reflect.Constructor; | import java.lang.reflect.Constructor; | ||||
| import java.lang.reflect.InvocationTargetException; | import java.lang.reflect.InvocationTargetException; | ||||
| import java.nio.file.Files; | |||||
| import java.util.zip.GZIPInputStream; | import java.util.zip.GZIPInputStream; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| @@ -97,7 +97,7 @@ public class Untar extends Expand { | |||||
| */ | */ | ||||
| /** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
| protected void expandFile(FileUtils fileUtils, File srcF, File dir) { | protected void expandFile(FileUtils fileUtils, File srcF, File dir) { | ||||
| FileInputStream fis = null; | |||||
| InputStream fis = null; | |||||
| if (!srcF.exists()) { | if (!srcF.exists()) { | ||||
| throw new BuildException("Unable to untar " | throw new BuildException("Unable to untar " | ||||
| + srcF | + srcF | ||||
| @@ -105,7 +105,7 @@ public class Untar extends Expand { | |||||
| getLocation()); | getLocation()); | ||||
| } | } | ||||
| try { | try { | ||||
| fis = new FileInputStream(srcF); | |||||
| fis = Files.newInputStream(srcF.toPath()); | |||||
| expandStream(srcF.getPath(), fis, dir); | expandStream(srcF.getPath(), fis, dir); | ||||
| } catch (IOException ioe) { | } catch (IOException ioe) { | ||||
| throw new BuildException("Error while expanding " + srcF.getPath() | throw new BuildException("Error while expanding " + srcF.getPath() | ||||
| @@ -20,11 +20,10 @@ package org.apache.tools.ant.taskdefs; | |||||
| import java.io.ByteArrayInputStream; | import java.io.ByteArrayInputStream; | ||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.nio.file.Files; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Arrays; | import java.util.Arrays; | ||||
| import java.util.Collections; | import java.util.Collections; | ||||
| @@ -1177,7 +1176,7 @@ public class Zip extends MatchingTask { | |||||
| } | } | ||||
| OutputStream os = null; | OutputStream os = null; | ||||
| try { | try { | ||||
| os = new FileOutputStream(zipFile); | |||||
| os = Files.newOutputStream(zipFile.toPath()); | |||||
| // CheckStyle:MagicNumber OFF | // CheckStyle:MagicNumber OFF | ||||
| // Cf. PKZIP specification. | // Cf. PKZIP specification. | ||||
| final byte[] empty = new byte[22]; | final byte[] empty = new byte[22]; | ||||
| @@ -1915,7 +1914,7 @@ public class Zip extends MatchingTask { | |||||
| getLocation()); | getLocation()); | ||||
| } | } | ||||
| try (FileInputStream fIn = new FileInputStream(file)) { | |||||
| try (InputStream fIn = Files.newInputStream(file.toPath())) { | |||||
| // ZIPs store time with a granularity of 2 seconds, round up | // ZIPs store time with a granularity of 2 seconds, round up | ||||
| zipFile(fIn, zOut, vPath, | zipFile(fIn, zOut, vPath, | ||||
| file.lastModified() + (roundUp ? ROUNDUP_MILLIS : 0), | file.lastModified() + (roundUp ? ROUNDUP_MILLIS : 0), | ||||
| @@ -18,12 +18,12 @@ | |||||
| package org.apache.tools.ant.taskdefs.cvslib; | package org.apache.tools.ant.taskdefs.cvslib; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | |||||
| import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
| import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
| import java.io.UnsupportedEncodingException; | import java.io.UnsupportedEncodingException; | ||||
| import java.nio.file.Files; | |||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| @@ -386,7 +386,7 @@ public class ChangeLogTask extends AbstractCvsTask { | |||||
| throws BuildException { | throws BuildException { | ||||
| if (null != usersFile) { | if (null != usersFile) { | ||||
| try { | try { | ||||
| userList.load(new FileInputStream(usersFile)); | |||||
| userList.load(Files.newInputStream(usersFile.toPath())); | |||||
| } catch (final IOException ioe) { | } catch (final IOException ioe) { | ||||
| throw new BuildException(ioe.toString(), ioe); | throw new BuildException(ioe.toString(), ioe); | ||||
| } | } | ||||
| @@ -462,10 +462,10 @@ public class ChangeLogTask extends AbstractCvsTask { | |||||
| */ | */ | ||||
| private void writeChangeLog(final CVSEntry[] entrySet) | private void writeChangeLog(final CVSEntry[] entrySet) | ||||
| throws BuildException { | throws BuildException { | ||||
| FileOutputStream output = null; | |||||
| OutputStream output = null; | |||||
| try { | try { | ||||
| output = new FileOutputStream(destFile); | |||||
| output = Files.newOutputStream(destFile.toPath()); | |||||
| final PrintWriter writer = | final PrintWriter writer = | ||||
| new PrintWriter(new OutputStreamWriter(output, "UTF-8")); | new PrintWriter(new OutputStreamWriter(output, "UTF-8")); | ||||
| @@ -19,12 +19,13 @@ package org.apache.tools.ant.taskdefs.cvslib; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | |||||
| import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
| import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
| import java.io.UnsupportedEncodingException; | import java.io.UnsupportedEncodingException; | ||||
| import java.nio.file.Files; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -417,9 +418,9 @@ public class CvsTagDiff extends AbstractCvsTask { | |||||
| * @exception BuildException if an error occurs | * @exception BuildException if an error occurs | ||||
| */ | */ | ||||
| private void writeTagDiff(CvsTagEntry[] entries) throws BuildException { | private void writeTagDiff(CvsTagEntry[] entries) throws BuildException { | ||||
| FileOutputStream output = null; | |||||
| OutputStream output = null; | |||||
| try { | try { | ||||
| output = new FileOutputStream(mydestfile); | |||||
| output = Files.newOutputStream(mydestfile.toPath()); | |||||
| PrintWriter writer = new PrintWriter( | PrintWriter writer = new PrintWriter( | ||||
| new OutputStreamWriter(output, "UTF-8")); | new OutputStreamWriter(output, "UTF-8")); | ||||
| writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); | writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); | ||||
| @@ -20,13 +20,14 @@ package org.apache.tools.ant.taskdefs.email; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | |||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.io.Reader; | import java.io.Reader; | ||||
| import java.nio.file.Files; | |||||
| import org.apache.tools.ant.ProjectComponent; | import org.apache.tools.ant.ProjectComponent; | ||||
| @@ -185,7 +186,7 @@ public class Message extends ProjectComponent { | |||||
| private Reader getReader(File f) throws IOException { | private Reader getReader(File f) throws IOException { | ||||
| if (inputEncoding != null) { | if (inputEncoding != null) { | ||||
| FileInputStream fis = new FileInputStream(f); | |||||
| InputStream fis = Files.newInputStream(f.toPath()); | |||||
| try { | try { | ||||
| return new InputStreamReader(fis, inputEncoding); | return new InputStreamReader(fis, inputEncoding); | ||||
| } catch (IOException ex) { | } catch (IOException ex) { | ||||
| @@ -19,9 +19,10 @@ package org.apache.tools.ant.taskdefs.email; | |||||
| import java.io.BufferedInputStream; | import java.io.BufferedInputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | |||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| @@ -148,7 +149,7 @@ class PlainMailer extends Mailer { | |||||
| final int maxBuf = 1024; | final int maxBuf = 1024; | ||||
| byte[] buf = new byte[maxBuf]; | byte[] buf = new byte[maxBuf]; | ||||
| try (FileInputStream finstr = new FileInputStream(file); | |||||
| try (InputStream finstr = Files.newInputStream(file.toPath()); | |||||
| BufferedInputStream in = new BufferedInputStream(finstr, buf.length)) { | BufferedInputStream in = new BufferedInputStream(finstr, buf.length)) { | ||||
| while ((length = in.read(buf)) != -1) { | while ((length = in.read(buf)) != -1) { | ||||
| @@ -19,9 +19,10 @@ package org.apache.tools.ant.taskdefs.email; | |||||
| import java.io.BufferedInputStream; | import java.io.BufferedInputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | |||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.nio.file.Files; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.util.UUEncoder; | import org.apache.tools.ant.util.UUEncoder; | ||||
| @@ -40,7 +41,7 @@ class UUMailer extends PlainMailer { | |||||
| + "readable."); | + "readable."); | ||||
| } | } | ||||
| try (FileInputStream finstr = new FileInputStream(file); | |||||
| try (InputStream finstr = Files.newInputStream(file.toPath()); | |||||
| BufferedInputStream in = new BufferedInputStream(finstr)) { | BufferedInputStream in = new BufferedInputStream(finstr)) { | ||||
| UUEncoder encoder = new UUEncoder(file.getName()); | UUEncoder encoder = new UUEncoder(file.getName()); | ||||
| @@ -19,13 +19,13 @@ package org.apache.tools.ant.taskdefs.optional; | |||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | |||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
| import java.io.Writer; | import java.io.Writer; | ||||
| import java.nio.file.Files; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Collections; | import java.util.Collections; | ||||
| import java.util.Comparator; | import java.util.Comparator; | ||||
| @@ -290,9 +290,9 @@ public class EchoProperties extends Task { | |||||
| return; | return; | ||||
| } | } | ||||
| FileInputStream in = null; | |||||
| InputStream in = null; | |||||
| try { | try { | ||||
| in = new FileInputStream(inFile); | |||||
| in = Files.newInputStream(inFile.toPath()); | |||||
| Properties props = new Properties(); | Properties props = new Properties(); | ||||
| props.load(in); | props.load(in); | ||||
| allProps.putAll(props); | allProps.putAll(props); | ||||
| @@ -352,7 +352,7 @@ public class EchoProperties extends Task { | |||||
| } | } | ||||
| return; | return; | ||||
| } | } | ||||
| os = new FileOutputStream(this.destfile); | |||||
| os = Files.newOutputStream(this.destfile.toPath()); | |||||
| saveProperties(allProps, os); | saveProperties(allProps, os); | ||||
| } | } | ||||
| } catch (IOException ioe) { | } catch (IOException ioe) { | ||||
| @@ -21,10 +21,10 @@ package org.apache.tools.ant.taskdefs.optional; | |||||
| import java.io.BufferedInputStream; | import java.io.BufferedInputStream; | ||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | |||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.nio.file.Files; | |||||
| import java.text.DateFormat; | import java.text.DateFormat; | ||||
| import java.text.DecimalFormat; | import java.text.DecimalFormat; | ||||
| import java.text.ParseException; | import java.text.ParseException; | ||||
| @@ -192,15 +192,15 @@ public class PropertyFile extends Task { | |||||
| if (propertyfile.exists()) { | if (propertyfile.exists()) { | ||||
| log("Updating property file: " | log("Updating property file: " | ||||
| + propertyfile.getAbsolutePath()); | + propertyfile.getAbsolutePath()); | ||||
| try (FileInputStream fis = new FileInputStream(propertyfile); | |||||
| try (InputStream fis = Files.newInputStream(propertyfile.toPath()); | |||||
| BufferedInputStream bis = new BufferedInputStream(fis)) { | BufferedInputStream bis = new BufferedInputStream(fis)) { | ||||
| properties.load(bis); | properties.load(bis); | ||||
| } | } | ||||
| } else { | } else { | ||||
| log("Creating new property file: " | log("Creating new property file: " | ||||
| + propertyfile.getAbsolutePath()); | + propertyfile.getAbsolutePath()); | ||||
| try (FileOutputStream out = | |||||
| new FileOutputStream(propertyfile.getAbsolutePath())) { | |||||
| try (OutputStream out = | |||||
| Files.newOutputStream(propertyfile.toPath())) { | |||||
| out.flush(); | out.flush(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -249,7 +249,7 @@ public class PropertyFile extends Task { | |||||
| throw new BuildException(x, getLocation()); | throw new BuildException(x, getLocation()); | ||||
| } | } | ||||
| try { | try { | ||||
| OutputStream os = new FileOutputStream(propertyfile); //NOSONAR | |||||
| OutputStream os = Files.newOutputStream(propertyfile.toPath()); //NOSONAR | |||||
| try { | try { | ||||
| try { | try { | ||||
| os.write(baos.toByteArray()); | os.write(baos.toByteArray()); | ||||
| @@ -20,8 +20,6 @@ package org.apache.tools.ant.taskdefs.optional; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| @@ -29,6 +27,7 @@ import java.io.OutputStream; | |||||
| import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
| import java.io.Reader; | import java.io.Reader; | ||||
| import java.io.Writer; | import java.io.Writer; | ||||
| import java.nio.file.Files; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| @@ -356,8 +355,8 @@ public class ReplaceRegExp extends Task { | |||||
| try { | try { | ||||
| boolean changes = false; | boolean changes = false; | ||||
| try (InputStream is = new FileInputStream(f); | |||||
| OutputStream os = new FileOutputStream(temp)) { | |||||
| try (InputStream is = Files.newInputStream(f.toPath()); | |||||
| OutputStream os = Files.newOutputStream(temp.toPath())) { | |||||
| Reader r = null; | Reader r = null; | ||||
| Writer w = null; | Writer w = null; | ||||
| try { | try { | ||||
| @@ -19,10 +19,10 @@ package org.apache.tools.ant.taskdefs.optional; | |||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| @@ -149,9 +149,9 @@ public class Rpm extends Task { | |||||
| } | } | ||||
| } else { | } else { | ||||
| if (output != null) { | if (output != null) { | ||||
| FileOutputStream fos = null; | |||||
| OutputStream fos = null; | |||||
| try { | try { | ||||
| fos = new FileOutputStream(output); //NOSONAR | |||||
| fos = Files.newOutputStream(output.toPath()); //NOSONAR | |||||
| BufferedOutputStream bos = new BufferedOutputStream(fos); | BufferedOutputStream bos = new BufferedOutputStream(fos); | ||||
| outputstream = new PrintStream(bos); | outputstream = new PrintStream(bos); | ||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| @@ -164,9 +164,9 @@ public class Rpm extends Task { | |||||
| outputstream = new LogOutputStream(this, Project.MSG_DEBUG); | outputstream = new LogOutputStream(this, Project.MSG_DEBUG); | ||||
| } | } | ||||
| if (error != null) { | if (error != null) { | ||||
| FileOutputStream fos = null; | |||||
| OutputStream fos = null; | |||||
| try { | try { | ||||
| fos = new FileOutputStream(error); | |||||
| fos = Files.newOutputStream(error.toPath()); | |||||
| BufferedOutputStream bos = new BufferedOutputStream(fos); | BufferedOutputStream bos = new BufferedOutputStream(fos); | ||||
| errorstream = new PrintStream(bos); | errorstream = new PrintStream(bos); | ||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| @@ -21,13 +21,12 @@ package org.apache.tools.ant.taskdefs.optional; | |||||
| import java.io.BufferedInputStream; | import java.io.BufferedInputStream; | ||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.lang.reflect.Field; | import java.lang.reflect.Field; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.nio.file.Files; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| @@ -191,8 +190,8 @@ public class TraXLiaison implements XSLTLiaison4, ErrorListener, XSLTLoggerAware | |||||
| InputStream fis = null; | InputStream fis = null; | ||||
| OutputStream fos = null; | OutputStream fos = null; | ||||
| try { | try { | ||||
| fis = new BufferedInputStream(new FileInputStream(infile)); | |||||
| fos = new BufferedOutputStream(new FileOutputStream(outfile)); | |||||
| fis = new BufferedInputStream(Files.newInputStream(infile.toPath())); | |||||
| fos = new BufferedOutputStream(Files.newOutputStream(outfile.toPath())); | |||||
| final StreamResult res = new StreamResult(fos); | final StreamResult res = new StreamResult(fos); | ||||
| // not sure what could be the need of this... | // not sure what could be the need of this... | ||||
| res.setSystemId(JAXPUtils.getSystemId(outfile)); | res.setSystemId(JAXPUtils.getSystemId(outfile)); | ||||
| @@ -18,8 +18,8 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional; | package org.apache.tools.ant.taskdefs.optional; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import org.apache.tools.ant.AntClassLoader; | import org.apache.tools.ant.AntClassLoader; | ||||
| @@ -550,7 +550,7 @@ public class XMLValidateTask extends Task { | |||||
| try { | try { | ||||
| log("Validating " + afile.getName() + "... ", Project.MSG_VERBOSE); | log("Validating " + afile.getName() + "... ", Project.MSG_VERBOSE); | ||||
| errorHandler.init(afile); | errorHandler.init(afile); | ||||
| InputSource is = new InputSource(new FileInputStream(afile)); | |||||
| InputSource is = new InputSource(Files.newInputStream(afile.toPath())); | |||||
| String uri = FILE_UTILS.toURI(afile.getAbsolutePath()); | String uri = FILE_UTILS.toURI(afile.getAbsolutePath()); | ||||
| is.setSystemId(uri); | is.setSystemId(uri); | ||||
| xmlReader.parse(is); | xmlReader.parse(is); | ||||
| @@ -18,9 +18,10 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.depend; | package org.apache.tools.ant.taskdefs.optional.depend; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.nio.file.Files; | |||||
| import java.nio.file.Paths; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| @@ -80,7 +81,7 @@ public class AntAnalyzer extends AbstractAnalyzer { | |||||
| InputStream inStream = null; | InputStream inStream = null; | ||||
| try { | try { | ||||
| if (container.getName().endsWith(".class")) { | if (container.getName().endsWith(".class")) { | ||||
| inStream = new FileInputStream(container.getPath()); | |||||
| inStream = Files.newInputStream(Paths.get(container.getPath())); | |||||
| } else { | } else { | ||||
| zipFile = new ZipFile(container.getPath()); | zipFile = new ZipFile(container.getPath()); | ||||
| String entryName | String entryName | ||||
| @@ -18,8 +18,9 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.depend; | package org.apache.tools.ant.taskdefs.optional.depend; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | |||||
| import java.nio.file.Files; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Stack; | import java.util.Stack; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| @@ -130,8 +131,8 @@ public class DirectoryIterator implements ClassFileIterator { | |||||
| } else { | } else { | ||||
| // we have a file. create a stream for it | // we have a file. create a stream for it | ||||
| try (FileInputStream inFileStream | |||||
| = new FileInputStream(element)) { | |||||
| try (InputStream inFileStream | |||||
| = Files.newInputStream(element.toPath())) { | |||||
| if (element.getName().endsWith(".class")) { | if (element.getName().endsWith(".class")) { | ||||
| // create a data input stream from the jar | // create a data input stream from the jar | ||||
| @@ -19,11 +19,10 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.ejb; | package org.apache.tools.ant.taskdefs.optional.ejb; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileNotFoundException; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| @@ -192,8 +191,8 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase { | |||||
| try { | try { | ||||
| owningTask.log("Resolved " + publicId + " to local file " | owningTask.log("Resolved " + publicId + " to local file " | ||||
| + dtdFile, Project.MSG_VERBOSE); | + dtdFile, Project.MSG_VERBOSE); | ||||
| return new InputSource(new FileInputStream(dtdFile)); | |||||
| } catch (FileNotFoundException ex) { | |||||
| return new InputSource(Files.newInputStream(dtdFile.toPath())); | |||||
| } catch (IOException ex) { | |||||
| // ignore | // ignore | ||||
| } | } | ||||
| } | } | ||||
| @@ -18,10 +18,9 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.ejb; | package org.apache.tools.ant.taskdefs.optional.ejb; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.HashSet; | import java.util.HashSet; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| @@ -327,10 +326,10 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||||
| File inputFile, | File inputFile, | ||||
| String logicalFilename) | String logicalFilename) | ||||
| throws BuildException { | throws BuildException { | ||||
| FileInputStream iStream = null; | |||||
| InputStream iStream = null; | |||||
| try { | try { | ||||
| if (!addedfiles.contains(logicalFilename)) { | if (!addedfiles.contains(logicalFilename)) { | ||||
| iStream = new FileInputStream(inputFile); | |||||
| iStream = Files.newInputStream(inputFile.toPath()); | |||||
| // Create the zip entry and add it to the jar file | // Create the zip entry and add it to the jar file | ||||
| ZipEntry zipEntry = new ZipEntry(logicalFilename.replace('\\', '/')); | ZipEntry zipEntry = new ZipEntry(logicalFilename.replace('\\', '/')); | ||||
| jStream.putNextEntry(zipEntry); | jStream.putNextEntry(zipEntry); | ||||
| @@ -514,7 +513,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||||
| */ | */ | ||||
| protected Hashtable parseEjbFiles(String descriptorFileName, SAXParser saxParser) | protected Hashtable parseEjbFiles(String descriptorFileName, SAXParser saxParser) | ||||
| throws IOException, SAXException { | throws IOException, SAXException { | ||||
| FileInputStream descriptorStream = null; | |||||
| InputStream descriptorStream = null; | |||||
| Hashtable ejbFiles = null; | Hashtable ejbFiles = null; | ||||
| try { | try { | ||||
| @@ -524,7 +523,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||||
| * get hold of all the classfile names for the descriptor. | * get hold of all the classfile names for the descriptor. | ||||
| */ | */ | ||||
| descriptorStream | descriptorStream | ||||
| = new FileInputStream(new File(config.descriptorDir, descriptorFileName)); | |||||
| = Files.newInputStream(new File(config.descriptorDir, descriptorFileName).toPath()); | |||||
| saxParser.parse(new InputSource(descriptorStream), handler); | saxParser.parse(new InputSource(descriptorStream), handler); | ||||
| ejbFiles = handler.getFiles(); | ejbFiles = handler.getFiles(); | ||||
| @@ -776,7 +775,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||||
| try { | try { | ||||
| File manifestFile = (File) files.get(MANIFEST); | File manifestFile = (File) files.get(MANIFEST); | ||||
| if (manifestFile != null && manifestFile.exists()) { | if (manifestFile != null && manifestFile.exists()) { | ||||
| in = new FileInputStream(manifestFile); | |||||
| in = Files.newInputStream(manifestFile.toPath()); | |||||
| } else { | } else { | ||||
| String defaultManifest = "/org/apache/tools/ant/defaultManifest.mf"; | String defaultManifest = "/org/apache/tools/ant/defaultManifest.mf"; | ||||
| in = this.getClass().getResourceAsStream(defaultManifest); | in = this.getClass().getResourceAsStream(defaultManifest); | ||||
| @@ -797,7 +796,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||||
| // Create the streams necessary to write the jarfile | // Create the streams necessary to write the jarfile | ||||
| jarStream = new JarOutputStream(new FileOutputStream(jarfile), manifest); | |||||
| jarStream = new JarOutputStream(Files.newOutputStream(jarfile.toPath()), manifest); | |||||
| jarStream.setMethod(JarOutputStream.DEFLATED); | jarStream.setMethod(JarOutputStream.DEFLATED); | ||||
| // Loop through all the class files found and add them to the jar | // Loop through all the class files found and add them to the jar | ||||
| @@ -20,10 +20,11 @@ package org.apache.tools.ant.taskdefs.optional.ejb; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| import java.nio.file.Files; | |||||
| import java.nio.file.Paths; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| @@ -729,7 +730,7 @@ public class IPlanetEjbc { | |||||
| location = (String) fileDtds.get(publicId); | location = (String) fileDtds.get(publicId); | ||||
| if (location != null) { | if (location != null) { | ||||
| // closed when the InputSource is closed | // closed when the InputSource is closed | ||||
| inputStream = new FileInputStream(location); //NOSONAR | |||||
| inputStream = Files.newInputStream(Paths.get(location)); //NOSONAR | |||||
| } | } | ||||
| } | } | ||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| @@ -18,10 +18,9 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.ejb; | package org.apache.tools.ant.taskdefs.optional.ejb; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| @@ -496,9 +495,8 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool { | |||||
| DescriptorHandler handler | DescriptorHandler handler | ||||
| = getWeblogicDescriptorHandler(ejbDescriptor.getParentFile()); | = getWeblogicDescriptorHandler(ejbDescriptor.getParentFile()); | ||||
| saxParser.parse(new InputSource | |||||
| (new FileInputStream(weblogicDD)), | |||||
| handler); | |||||
| saxParser.parse(new InputSource(Files.newInputStream(weblogicDD.toPath())), | |||||
| handler); | |||||
| Hashtable ht = handler.getFiles(); | Hashtable ht = handler.getFiles(); | ||||
| Enumeration e = ht.keys(); | Enumeration e = ht.keys(); | ||||
| @@ -810,7 +808,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool { | |||||
| newWLJarFile.delete(); | newWLJarFile.delete(); | ||||
| } | } | ||||
| newJarStream = new JarOutputStream(new FileOutputStream(newWLJarFile)); | |||||
| newJarStream = new JarOutputStream(Files.newOutputStream(newWLJarFile.toPath())); | |||||
| newJarStream.setLevel(0); | newJarStream.setLevel(0); | ||||
| //Copy files from old weblogic jar | //Copy files from old weblogic jar | ||||
| @@ -18,9 +18,9 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.ejb; | package org.apache.tools.ant.taskdefs.optional.ejb; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| @@ -775,7 +775,7 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool { | |||||
| newwasJarFile.delete(); | newwasJarFile.delete(); | ||||
| } | } | ||||
| newJarStream = new JarOutputStream(new FileOutputStream(newwasJarFile)); | |||||
| newJarStream = new JarOutputStream(Files.newOutputStream(newwasJarFile.toPath())); | |||||
| newJarStream.setLevel(0); | newJarStream.setLevel(0); | ||||
| //Copy files from old websphere jar | //Copy files from old websphere jar | ||||
| @@ -18,8 +18,9 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.extension; | package org.apache.tools.ant.taskdefs.optional.extension; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | |||||
| import java.nio.file.Files; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.jar.Attributes; | import java.util.jar.Attributes; | ||||
| @@ -214,9 +215,9 @@ public final class JarLibManifestTask extends Task { | |||||
| * @throws IOException if error writing file | * @throws IOException if error writing file | ||||
| */ | */ | ||||
| private void writeManifest(final Manifest manifest) throws IOException { | private void writeManifest(final Manifest manifest) throws IOException { | ||||
| FileOutputStream output = null; | |||||
| OutputStream output = null; | |||||
| try { | try { | ||||
| output = new FileOutputStream(destFile); | |||||
| output = Files.newOutputStream(destFile.toPath()); | |||||
| manifest.write(output); | manifest.write(output); | ||||
| output.flush(); | output.flush(); | ||||
| } finally { | } finally { | ||||
| @@ -20,11 +20,12 @@ package org.apache.tools.ant.taskdefs.optional.i18n; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | |||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| import java.io.OutputStream; | |||||
| import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Locale; | import java.util.Locale; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| @@ -407,9 +408,9 @@ public class Translate extends MatchingTask { | |||||
| private void processBundle(final String bundleFile, final int i, | private void processBundle(final String bundleFile, final int i, | ||||
| final boolean checkLoaded) throws BuildException { | final boolean checkLoaded) throws BuildException { | ||||
| final File propsFile = getProject().resolveFile(bundleFile + ".properties"); | final File propsFile = getProject().resolveFile(bundleFile + ".properties"); | ||||
| FileInputStream ins = null; | |||||
| InputStream ins = null; | |||||
| try { | try { | ||||
| ins = new FileInputStream(propsFile); | |||||
| ins = Files.newInputStream(propsFile.toPath()); | |||||
| loaded = true; | loaded = true; | ||||
| bundleLastModified[i] = propsFile.lastModified(); | bundleLastModified[i] = propsFile.lastModified(); | ||||
| log("Using " + propsFile, Project.MSG_DEBUG); | log("Using " + propsFile, Project.MSG_DEBUG); | ||||
| @@ -429,7 +430,7 @@ public class Translate extends MatchingTask { | |||||
| * Load resourceMap with key value pairs. Values of existing keys | * Load resourceMap with key value pairs. Values of existing keys | ||||
| * are not overwritten. Bundle's encoding scheme is used. | * are not overwritten. Bundle's encoding scheme is used. | ||||
| */ | */ | ||||
| private void loadResourceMap(FileInputStream ins) throws BuildException { | |||||
| private void loadResourceMap(InputStream ins) throws BuildException { | |||||
| try { | try { | ||||
| BufferedReader in = null; | BufferedReader in = null; | ||||
| InputStreamReader isr = new InputStreamReader(ins, bundleEncoding); | InputStreamReader isr = new InputStreamReader(ins, bundleEncoding); | ||||
| @@ -551,9 +552,9 @@ public class Translate extends MatchingTask { | |||||
| BufferedWriter out = null; | BufferedWriter out = null; | ||||
| BufferedReader in = null; | BufferedReader in = null; | ||||
| try { | try { | ||||
| FileOutputStream fos = new FileOutputStream(dest); | |||||
| OutputStream fos = Files.newOutputStream(dest.toPath()); | |||||
| out = new BufferedWriter(new OutputStreamWriter(fos, destEncoding)); | out = new BufferedWriter(new OutputStreamWriter(fos, destEncoding)); | ||||
| FileInputStream fis = new FileInputStream(src); | |||||
| InputStream fis = Files.newInputStream(src.toPath()); | |||||
| in = new BufferedReader(new InputStreamReader(fis, srcEncoding)); | in = new BufferedReader(new InputStreamReader(fis, srcEncoding)); | ||||
| String line; | String line; | ||||
| LineTokenizer lineTokenizer = new LineTokenizer(); | LineTokenizer lineTokenizer = new LineTokenizer(); | ||||
| @@ -18,8 +18,9 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.image; | package org.apache.tools.ant.taskdefs.optional.image; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | |||||
| import java.nio.file.Files; | |||||
| import java.util.Locale; | import java.util.Locale; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| @@ -316,9 +317,9 @@ public class Image extends MatchingTask { | |||||
| newFile.delete(); | newFile.delete(); | ||||
| } | } | ||||
| FileOutputStream stream = null; | |||||
| OutputStream stream = null; | |||||
| try { | try { | ||||
| stream = new FileOutputStream(newFile); | |||||
| stream = Files.newOutputStream(newFile.toPath()); | |||||
| JAI.create("encode", image, stream, | JAI.create("encode", image, stream, | ||||
| str_encoding.toUpperCase(Locale.ENGLISH), | str_encoding.toUpperCase(Locale.ENGLISH), | ||||
| @@ -24,10 +24,10 @@ package org.apache.tools.ant.taskdefs.optional.jlink; | |||||
| import java.io.BufferedInputStream; | import java.io.BufferedInputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.nio.file.Files; | |||||
| import java.nio.file.Paths; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| import java.util.zip.CRC32; | import java.util.zip.CRC32; | ||||
| @@ -145,7 +145,7 @@ public class jlink { | |||||
| * @throws Exception on error. | * @throws Exception on error. | ||||
| */ | */ | ||||
| public void link() throws Exception { //NOSONAR | public void link() throws Exception { //NOSONAR | ||||
| ZipOutputStream output = new ZipOutputStream(new FileOutputStream(outfile)); | |||||
| ZipOutputStream output = new ZipOutputStream(Files.newOutputStream(Paths.get(outfile))); | |||||
| if (compression) { | if (compression) { | ||||
| output.setMethod(ZipOutputStream.DEFLATED); | output.setMethod(ZipOutputStream.DEFLATED); | ||||
| @@ -303,7 +303,7 @@ public class jlink { | |||||
| // see if the file is in fact a .class file, and determine its actual name. | // see if the file is in fact a .class file, and determine its actual name. | ||||
| InputStream input = null; | InputStream input = null; | ||||
| try { | try { | ||||
| input = new FileInputStream(file); | |||||
| input = Files.newInputStream(file.toPath()); | |||||
| String className = ClassNameReader.getClassName(input); | String className = ClassNameReader.getClassName(input); | ||||
| if (className != null) { | if (className != null) { | ||||
| @@ -337,7 +337,7 @@ public class jlink { | |||||
| if (!compress) { | if (!compress) { | ||||
| entry.setCrc(calcChecksum(file)); | entry.setCrc(calcChecksum(file)); | ||||
| } | } | ||||
| FileInputStream input = new FileInputStream(file); | |||||
| InputStream input = Files.newInputStream(file.toPath()); | |||||
| addToOutputStream(output, input, entry); | addToOutputStream(output, input, entry); | ||||
| } | } | ||||
| @@ -422,7 +422,7 @@ public class jlink { | |||||
| * is not compressed. | * is not compressed. | ||||
| */ | */ | ||||
| private long calcChecksum(File f) throws IOException { | private long calcChecksum(File f) throws IOException { | ||||
| BufferedInputStream in = new BufferedInputStream(new FileInputStream(f)); | |||||
| BufferedInputStream in = new BufferedInputStream(Files.newInputStream(f.toPath())); | |||||
| return calcChecksum(in); | return calcChecksum(in); | ||||
| } | } | ||||
| @@ -18,11 +18,11 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.junit; | package org.apache.tools.ant.taskdefs.optional.junit; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| @@ -176,7 +176,7 @@ public class AggregateTransformer { | |||||
| protected void setXmlfile(File xmlfile) throws BuildException { | protected void setXmlfile(File xmlfile) throws BuildException { | ||||
| try { | try { | ||||
| DocumentBuilder builder = privateDBFactory.newDocumentBuilder(); | DocumentBuilder builder = privateDBFactory.newDocumentBuilder(); | ||||
| try (InputStream in = new FileInputStream(xmlfile)) { | |||||
| try (InputStream in = Files.newInputStream(xmlfile.toPath())) { | |||||
| Document doc = builder.parse(in); | Document doc = builder.parse(in); | ||||
| setXmlDocument(doc); | setXmlDocument(doc); | ||||
| } | } | ||||
| @@ -20,12 +20,12 @@ package org.apache.tools.ant.taskdefs.optional.junit; | |||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.lang.reflect.Field; | import java.lang.reflect.Field; | ||||
| import java.lang.reflect.InvocationTargetException; | import java.lang.reflect.InvocationTargetException; | ||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
| import java.nio.file.Files; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| @@ -378,7 +378,7 @@ public class FormatterElement { | |||||
| public void write(int b) throws IOException { | public void write(int b) throws IOException { | ||||
| synchronized (this) { | synchronized (this) { | ||||
| if (outputStream == null) { | if (outputStream == null) { | ||||
| outputStream = new BufferedOutputStream(new FileOutputStream(file)); | |||||
| outputStream = new BufferedOutputStream(Files.newOutputStream(file.toPath())); | |||||
| } | } | ||||
| } | } | ||||
| outputStream.write(b); | outputStream.write(b); | ||||
| @@ -21,7 +21,6 @@ package org.apache.tools.ant.taskdefs.optional.junit; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| @@ -29,6 +28,7 @@ import java.io.OutputStream; | |||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.lang.reflect.Constructor; | import java.lang.reflect.Constructor; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.nio.file.Files; | |||||
| import java.security.AccessController; | import java.security.AccessController; | ||||
| import java.security.PrivilegedAction; | import java.security.PrivilegedAction; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| @@ -1243,7 +1243,7 @@ public class JUnitTask extends Task { | |||||
| props.put(key, p.get(key)); | props.put(key, p.get(key)); | ||||
| } | } | ||||
| try { | try { | ||||
| final FileOutputStream outstream = new FileOutputStream(propsFile); | |||||
| final OutputStream outstream = Files.newOutputStream(propsFile.toPath()); | |||||
| props.store(outstream, "Ant JUnitTask generated properties file"); | props.store(outstream, "Ant JUnitTask generated properties file"); | ||||
| outstream.close(); | outstream.close(); | ||||
| } catch (final java.io.IOException e) { | } catch (final java.io.IOException e) { | ||||
| @@ -1953,7 +1953,7 @@ public class JUnitTask extends Task { | |||||
| final File outFile = getOutput(fe, test); | final File outFile = getOutput(fe, test); | ||||
| if (outFile != null) { | if (outFile != null) { | ||||
| try { | try { | ||||
| out = new FileOutputStream(outFile); | |||||
| out = Files.newOutputStream(outFile.toPath()); | |||||
| } catch (final IOException e) { | } catch (final IOException e) { | ||||
| // ignore | // ignore | ||||
| } | } | ||||
| @@ -22,15 +22,17 @@ import java.io.BufferedReader; | |||||
| import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | |||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.io.StringReader; | import java.io.StringReader; | ||||
| import java.io.StringWriter; | import java.io.StringWriter; | ||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
| import java.lang.reflect.Modifier; | import java.lang.reflect.Modifier; | ||||
| import java.nio.file.Files; | |||||
| import java.nio.file.Paths; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| @@ -940,8 +942,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
| System.exit(ERRORS); | System.exit(ERRORS); | ||||
| } | } | ||||
| } else if (args[i].startsWith(Constants.PROPSFILE)) { | } else if (args[i].startsWith(Constants.PROPSFILE)) { | ||||
| final FileInputStream in = new FileInputStream(args[i] | |||||
| .substring(Constants.PROPSFILE.length())); | |||||
| final InputStream in = Files.newInputStream(Paths.get(args[i] | |||||
| .substring(Constants.PROPSFILE.length()))); | |||||
| props.load(in); | props.load(in); | ||||
| in.close(); | in.close(); | ||||
| } else if (args[i].startsWith(Constants.SHOWOUTPUT)) { | } else if (args[i].startsWith(Constants.SHOWOUTPUT)) { | ||||
| @@ -19,11 +19,11 @@ package org.apache.tools.ant.taskdefs.optional.junit; | |||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
| import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| @@ -213,7 +213,7 @@ public class XMLResultAggregator extends Task implements XMLConstants { | |||||
| * @throws IOException thrown if there is an error while writing the content. | * @throws IOException thrown if there is an error while writing the content. | ||||
| */ | */ | ||||
| protected void writeDOMTree(Document doc, File file) throws IOException { | protected void writeDOMTree(Document doc, File file) throws IOException { | ||||
| try (OutputStream os = new FileOutputStream(file); | |||||
| try (OutputStream os = Files.newOutputStream(file.toPath()); | |||||
| PrintWriter wri = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(os), "UTF8"))) { | PrintWriter wri = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(os), "UTF8"))) { | ||||
| wri.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); | wri.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); | ||||
| (new DOMElementWriter()).write(doc.getDocumentElement(), wri, 0, " "); | (new DOMElementWriter()).write(doc.getDocumentElement(), wri, 0, " "); | ||||
| @@ -20,14 +20,13 @@ package org.apache.tools.ant.taskdefs.optional.native2ascii; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
| import java.io.Writer; | import java.io.Writer; | ||||
| import java.nio.file.Files; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.taskdefs.optional.Native2Ascii; | import org.apache.tools.ant.taskdefs.optional.Native2Ascii; | ||||
| @@ -61,7 +60,7 @@ public class BuiltinNative2Ascii implements Native2AsciiAdapter { | |||||
| boolean reverse) throws IOException { | boolean reverse) throws IOException { | ||||
| if (!reverse && encoding != null) { | if (!reverse && encoding != null) { | ||||
| return new BufferedReader(new InputStreamReader( | return new BufferedReader(new InputStreamReader( | ||||
| new FileInputStream(srcFile), encoding)); | |||||
| Files.newInputStream(srcFile.toPath()), encoding)); | |||||
| } | } | ||||
| return new BufferedReader(new FileReader(srcFile)); | return new BufferedReader(new FileReader(srcFile)); | ||||
| } | } | ||||
| @@ -73,7 +72,7 @@ public class BuiltinNative2Ascii implements Native2AsciiAdapter { | |||||
| } | } | ||||
| if (encoding != null) { | if (encoding != null) { | ||||
| return new BufferedWriter( | return new BufferedWriter( | ||||
| new OutputStreamWriter(new FileOutputStream(destFile), | |||||
| new OutputStreamWriter(Files.newOutputStream(destFile.toPath()), | |||||
| encoding)); | encoding)); | ||||
| } | } | ||||
| return new BufferedWriter(new FileWriter(destFile)); | return new BufferedWriter(new FileWriter(destFile)); | ||||
| @@ -21,12 +21,11 @@ import java.io.BufferedInputStream; | |||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.nio.file.Files; | |||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.Collection; | import java.util.Collection; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| @@ -1957,7 +1956,7 @@ public class FTP extends Task implements FTPTaskConfig { | |||||
| // create a local temporary file | // create a local temporary file | ||||
| FILE_UTILS.createNewFile(tempFile); | FILE_UTILS.createNewFile(tempFile); | ||||
| long localTimeStamp = tempFile.lastModified(); | long localTimeStamp = tempFile.lastModified(); | ||||
| BufferedInputStream instream = new BufferedInputStream(new FileInputStream(tempFile)); | |||||
| BufferedInputStream instream = new BufferedInputStream(Files.newInputStream(tempFile.toPath())); | |||||
| ftp.storeFile(tempFile.getName(), instream); | ftp.storeFile(tempFile.getName(), instream); | ||||
| instream.close(); | instream.close(); | ||||
| boolean success = FTPReply.isPositiveCompletion(ftp.getReplyCode()); | boolean success = FTPReply.isPositiveCompletion(ftp.getReplyCode()); | ||||
| @@ -2148,7 +2147,7 @@ public class FTP extends Task implements FTPTaskConfig { | |||||
| log("transferring " + file.getAbsolutePath()); | log("transferring " + file.getAbsolutePath()); | ||||
| } | } | ||||
| instream = new BufferedInputStream(new FileInputStream(file)); | |||||
| instream = new BufferedInputStream(Files.newInputStream(file.toPath())); | |||||
| createParents(ftp, filename); | createParents(ftp, filename); | ||||
| @@ -2278,7 +2277,7 @@ public class FTP extends Task implements FTPTaskConfig { | |||||
| if (!pdir.exists()) { | if (!pdir.exists()) { | ||||
| pdir.mkdirs(); | pdir.mkdirs(); | ||||
| } | } | ||||
| outstream = new BufferedOutputStream(new FileOutputStream(file)); | |||||
| outstream = new BufferedOutputStream(Files.newOutputStream(file.toPath())); | |||||
| ftp.retrieveFile(resolveFile(filename), outstream); | ftp.retrieveFile(resolveFile(filename), outstream); | ||||
| if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { | if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { | ||||
| @@ -21,12 +21,11 @@ import java.io.BufferedInputStream; | |||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.nio.file.Files; | |||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| @@ -1346,7 +1345,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||||
| // create a local temporary file | // create a local temporary file | ||||
| FILE_UTILS.createNewFile(tempFile); | FILE_UTILS.createNewFile(tempFile); | ||||
| long localTimeStamp = tempFile.lastModified(); | long localTimeStamp = tempFile.lastModified(); | ||||
| BufferedInputStream instream = new BufferedInputStream(new FileInputStream(tempFile)); | |||||
| BufferedInputStream instream = new BufferedInputStream(Files.newInputStream(tempFile.toPath())); | |||||
| ftp.storeFile(tempFile.getName(), instream); | ftp.storeFile(tempFile.getName(), instream); | ||||
| instream.close(); | instream.close(); | ||||
| boolean success = FTPReply.isPositiveCompletion(ftp.getReplyCode()); | boolean success = FTPReply.isPositiveCompletion(ftp.getReplyCode()); | ||||
| @@ -1535,7 +1534,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||||
| task.log("transferring " + file.getAbsolutePath()); | task.log("transferring " + file.getAbsolutePath()); | ||||
| } | } | ||||
| instream = new BufferedInputStream(new FileInputStream(file)); | |||||
| instream = new BufferedInputStream(Files.newInputStream(file.toPath())); | |||||
| createParents(ftp, filename); | createParents(ftp, filename); | ||||
| @@ -1666,7 +1665,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { | |||||
| if (!pdir.exists()) { | if (!pdir.exists()) { | ||||
| pdir.mkdirs(); | pdir.mkdirs(); | ||||
| } | } | ||||
| outstream = new BufferedOutputStream(new FileOutputStream(file)); | |||||
| outstream = new BufferedOutputStream(Files.newOutputStream(file.toPath())); | |||||
| ftp.retrieveFile(resolveFile(filename), outstream); | ftp.retrieveFile(resolveFile(filename), outstream); | ||||
| if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { | if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { | ||||
| @@ -21,10 +21,11 @@ import java.io.BufferedReader; | |||||
| import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | |||||
| import java.nio.file.Files; | |||||
| import java.text.MessageFormat; | import java.text.MessageFormat; | ||||
| import java.text.ParseException; | import java.text.ParseException; | ||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| @@ -198,7 +199,7 @@ public class Pvcs extends org.apache.tools.ant.Task { | |||||
| try { | try { | ||||
| Random rand = new Random(System.currentTimeMillis()); | Random rand = new Random(System.currentTimeMillis()); | ||||
| tmp = new File("pvcs_ant_" + rand.nextLong() + ".log"); | tmp = new File("pvcs_ant_" + rand.nextLong() + ".log"); | ||||
| FileOutputStream fos = new FileOutputStream(tmp); | |||||
| OutputStream fos = Files.newOutputStream(tmp.toPath()); | |||||
| tmp2 = new File("pvcs_ant_" + rand.nextLong() + ".log"); | tmp2 = new File("pvcs_ant_" + rand.nextLong() + ".log"); | ||||
| log(commandLine.describeCommand(), Project.MSG_VERBOSE); | log(commandLine.describeCommand(), Project.MSG_VERBOSE); | ||||
| try { | try { | ||||
| @@ -22,13 +22,13 @@ import java.io.BufferedReader; | |||||
| import java.io.ByteArrayInputStream; | import java.io.ByteArrayInputStream; | ||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.io.StringReader; | import java.io.StringReader; | ||||
| import java.nio.file.Files; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| @@ -360,7 +360,7 @@ public class SSHExec extends SSHBase { | |||||
| InputStream istream = null; | InputStream istream = null; | ||||
| if (inputFile != null) { | if (inputFile != null) { | ||||
| try { | try { | ||||
| istream = new FileInputStream(inputFile); | |||||
| istream = Files.newInputStream(inputFile.toPath()); | |||||
| } catch (final IOException e) { | } catch (final IOException e) { | ||||
| // because we checked the existence before, this one | // because we checked the existence before, this one | ||||
| // shouldn't happen What if the file exists, but there | // shouldn't happen What if the file exists, but there | ||||
| @@ -21,10 +21,10 @@ package org.apache.tools.ant.taskdefs.optional.ssh; | |||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| import java.io.EOFException; | import java.io.EOFException; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.nio.file.Files; | |||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -262,7 +262,7 @@ public class ScpFromMessage extends AbstractSshMessage { | |||||
| sendAck(out); | sendAck(out); | ||||
| // read a content of lfile | // read a content of lfile | ||||
| final FileOutputStream fos = new FileOutputStream(localFile); | |||||
| final OutputStream fos = Files.newOutputStream(localFile.toPath()); | |||||
| int length; | int length; | ||||
| long totalLength = 0; | long totalLength = 0; | ||||
| final long startTime = System.currentTimeMillis(); | final long startTime = System.currentTimeMillis(); | ||||
| @@ -19,10 +19,10 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.ssh; | package org.apache.tools.ant.taskdefs.optional.ssh; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -363,7 +363,7 @@ public class ScpToMessage extends AbstractSshMessage { | |||||
| waitForAck(in); | waitForAck(in); | ||||
| // send a content of lfile | // send a content of lfile | ||||
| final FileInputStream fis = new FileInputStream(localFile); | |||||
| final InputStream fis = Files.newInputStream(localFile.toPath()); | |||||
| final byte[] buf = new byte[BUFFER_SIZE]; | final byte[] buf = new byte[BUFFER_SIZE]; | ||||
| final long startTime = System.currentTimeMillis(); | final long startTime = System.currentTimeMillis(); | ||||
| long totalLength = 0; | long totalLength = 0; | ||||
| @@ -32,12 +32,12 @@ package org.apache.tools.ant.taskdefs.optional.unix; | |||||
| import java.io.BufferedInputStream; | import java.io.BufferedInputStream; | ||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileNotFoundException; | import java.io.FileNotFoundException; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | |||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.nio.file.Files; | |||||
| import java.util.HashSet; | import java.util.HashSet; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| @@ -437,7 +437,7 @@ public class Symlink extends DispatchTask { | |||||
| BufferedOutputStream bos = null; | BufferedOutputStream bos = null; | ||||
| try { | try { | ||||
| bos = new BufferedOutputStream( | bos = new BufferedOutputStream( | ||||
| new FileOutputStream(new File(dir, linkFileName))); | |||||
| Files.newOutputStream(new File(dir, linkFileName).toPath())); | |||||
| properties.store(bos, "Symlinks from " + dir); | properties.store(bos, "Symlinks from " + dir); | ||||
| } catch (IOException ioe) { | } catch (IOException ioe) { | ||||
| throw new BuildException(ioe, getLocation()); | throw new BuildException(ioe, getLocation()); | ||||
| @@ -567,7 +567,7 @@ public class Symlink extends DispatchTask { | |||||
| Properties lnks = new Properties(); | Properties lnks = new Properties(); | ||||
| InputStream is = null; | InputStream is = null; | ||||
| try { | try { | ||||
| is = new BufferedInputStream(new FileInputStream(inc)); | |||||
| is = new BufferedInputStream(Files.newInputStream(inc.toPath())); | |||||
| lnks.load(is); | lnks.load(is); | ||||
| pf = pf.getCanonicalFile(); | pf = pf.getCanonicalFile(); | ||||
| } catch (FileNotFoundException fnfe) { | } catch (FileNotFoundException fnfe) { | ||||
| @@ -18,9 +18,10 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.xz; | package org.apache.tools.ant.taskdefs.optional.xz; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | |||||
| import java.nio.file.Files; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.taskdefs.Unpack; | import org.apache.tools.ant.taskdefs.Unpack; | ||||
| @@ -57,11 +58,11 @@ public class Unxz extends Unpack { | |||||
| log("Expanding " + srcResource.getName() + " to " | log("Expanding " + srcResource.getName() + " to " | ||||
| + dest.getAbsolutePath()); | + dest.getAbsolutePath()); | ||||
| FileOutputStream out = null; | |||||
| OutputStream out = null; | |||||
| XZInputStream zIn = null; | XZInputStream zIn = null; | ||||
| InputStream fis = null; | InputStream fis = null; | ||||
| try { | try { | ||||
| out = new FileOutputStream(dest); | |||||
| out = Files.newOutputStream(dest.toPath()); | |||||
| fis = srcResource.getInputStream(); | fis = srcResource.getInputStream(); | ||||
| zIn = new XZInputStream(fis); | zIn = new XZInputStream(fis); | ||||
| byte[] buffer = new byte[BUFFER_SIZE]; | byte[] buffer = new byte[BUFFER_SIZE]; | ||||
| @@ -19,8 +19,8 @@ | |||||
| package org.apache.tools.ant.taskdefs.optional.xz; | package org.apache.tools.ant.taskdefs.optional.xz; | ||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.nio.file.Files; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -44,7 +44,7 @@ public class Xz extends Pack { | |||||
| protected void pack() { | protected void pack() { | ||||
| XZOutputStream zOut = null; | XZOutputStream zOut = null; | ||||
| try { | try { | ||||
| zOut = new XZOutputStream(new FileOutputStream(zipFile), | |||||
| zOut = new XZOutputStream(Files.newOutputStream(zipFile.toPath()), | |||||
| new LZMA2Options()); | new LZMA2Options()); | ||||
| zipResource(getSrcResource(), zOut); | zipResource(getSrcResource(), zOut); | ||||
| } catch (IOException ioe) { | } catch (IOException ioe) { | ||||
| @@ -18,7 +18,8 @@ | |||||
| package org.apache.tools.ant.types; | package org.apache.tools.ant.types; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.InputStream; | |||||
| import java.nio.file.Files; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Hashtable; | import java.util.Hashtable; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -367,10 +368,10 @@ public class FilterSet extends DataType implements Cloneable { | |||||
| } | } | ||||
| if (filtersFile.isFile()) { | if (filtersFile.isFile()) { | ||||
| log("Reading filters from " + filtersFile, Project.MSG_VERBOSE); | log("Reading filters from " + filtersFile, Project.MSG_VERBOSE); | ||||
| FileInputStream in = null; | |||||
| InputStream in = null; | |||||
| try { | try { | ||||
| Properties props = new Properties(); | Properties props = new Properties(); | ||||
| in = new FileInputStream(filtersFile); | |||||
| in = Files.newInputStream(filtersFile.toPath()); | |||||
| props.load(in); | props.load(in); | ||||
| Enumeration<?> e = props.propertyNames(); | Enumeration<?> e = props.propertyNames(); | ||||
| @@ -19,13 +19,13 @@ | |||||
| package org.apache.tools.ant.types; | package org.apache.tools.ant.types; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
| import java.net.MalformedURLException; | import java.net.MalformedURLException; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.net.URLConnection; | import java.net.URLConnection; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Stack; | import java.util.Stack; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| @@ -677,7 +677,7 @@ public class XMLCatalog extends DataType | |||||
| File resFile = new File(fileName); | File resFile = new File(fileName); | ||||
| if (resFile.exists() && resFile.canRead()) { | if (resFile.exists() && resFile.canRead()) { | ||||
| try { | try { | ||||
| source = new InputSource(new FileInputStream(resFile)); | |||||
| source = new InputSource(Files.newInputStream(resFile.toPath())); | |||||
| String sysid = JAXPUtils.getSystemId(resFile); | String sysid = JAXPUtils.getSystemId(resFile); | ||||
| source.setSystemId(sysid); | source.setSystemId(sysid); | ||||
| log("catalog entry matched a readable file: '" | log("catalog entry matched a readable file: '" | ||||
| @@ -18,11 +18,10 @@ | |||||
| package org.apache.tools.ant.types.resources; | package org.apache.tools.ant.types.resources; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.nio.file.Files; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| @@ -216,7 +215,7 @@ public class FileResource extends Resource implements Touchable, FileProvider, | |||||
| public InputStream getInputStream() throws IOException { | public InputStream getInputStream() throws IOException { | ||||
| return isReference() | return isReference() | ||||
| ? ((Resource) getCheckedRef()).getInputStream() | ? ((Resource) getCheckedRef()).getInputStream() | ||||
| : new FileInputStream(getNotNullFile()); | |||||
| : Files.newInputStream(getNotNullFile().toPath()); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -256,7 +255,7 @@ public class FileResource extends Resource implements Touchable, FileProvider, | |||||
| p.mkdirs(); | p.mkdirs(); | ||||
| } | } | ||||
| } | } | ||||
| return append ? new FileOutputStream(f.getAbsolutePath(), true) : new FileOutputStream(f); | |||||
| return FileUtils.newOutputStream(f.toPath(), append); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -20,7 +20,8 @@ package org.apache.tools.ant.types.selectors.modifiedselector; | |||||
| import java.io.BufferedInputStream; | import java.io.BufferedInputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.InputStream; | |||||
| import java.nio.file.Files; | |||||
| import java.security.NoSuchAlgorithmException; | import java.security.NoSuchAlgorithmException; | ||||
| import java.util.Locale; | import java.util.Locale; | ||||
| import java.util.zip.Adler32; | import java.util.zip.Adler32; | ||||
| @@ -121,7 +122,7 @@ public class ChecksumAlgorithm implements Algorithm { | |||||
| try { | try { | ||||
| if (file.canRead()) { | if (file.canRead()) { | ||||
| checksum.reset(); | checksum.reset(); | ||||
| FileInputStream fis = new FileInputStream(file); | |||||
| InputStream fis = Files.newInputStream(file.toPath()); | |||||
| CheckedInputStream check = new CheckedInputStream(fis, checksum); | CheckedInputStream check = new CheckedInputStream(fis, checksum); | ||||
| BufferedInputStream in = new BufferedInputStream(check); | BufferedInputStream in = new BufferedInputStream(check); | ||||
| while (in.read() != -1) { | while (in.read() != -1) { | ||||
| @@ -20,7 +20,8 @@ package org.apache.tools.ant.types.selectors.modifiedselector; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.InputStream; | |||||
| import java.nio.file.Files; | |||||
| import java.security.DigestInputStream; | import java.security.DigestInputStream; | ||||
| import java.security.MessageDigest; | import java.security.MessageDigest; | ||||
| import java.security.NoSuchAlgorithmException; | import java.security.NoSuchAlgorithmException; | ||||
| @@ -158,12 +159,12 @@ public class DigestAlgorithm implements Algorithm { | |||||
| if (!file.canRead()) { | if (!file.canRead()) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| FileInputStream fis = null; | |||||
| InputStream fis = null; | |||||
| byte[] buf = new byte[readBufferSize]; | byte[] buf = new byte[readBufferSize]; | ||||
| try { | try { | ||||
| messageDigest.reset(); | messageDigest.reset(); | ||||
| fis = new FileInputStream(file); | |||||
| fis = Files.newInputStream(file.toPath()); | |||||
| DigestInputStream dis = new DigestInputStream(fis, | DigestInputStream dis = new DigestInputStream(fis, | ||||
| messageDigest); | messageDigest); | ||||
| while (dis.read(buf, 0, readBufferSize) != -1) { | while (dis.read(buf, 0, readBufferSize) != -1) { | ||||
| @@ -22,8 +22,9 @@ package org.apache.tools.ant.types.selectors.modifiedselector; | |||||
| import java.io.BufferedInputStream; | import java.io.BufferedInputStream; | ||||
| import java.io.BufferedOutputStream; | import java.io.BufferedOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.InputStream; | |||||
| import java.io.OutputStream; | |||||
| import java.nio.file.Files; | |||||
| import java.util.Enumeration; | import java.util.Enumeration; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.Properties; | import java.util.Properties; | ||||
| @@ -133,7 +134,7 @@ public class PropertiesfileCache implements Cache { | |||||
| if ((cachefile != null) && cachefile.isFile() && cachefile.canRead()) { | if ((cachefile != null) && cachefile.isFile() && cachefile.canRead()) { | ||||
| try { | try { | ||||
| BufferedInputStream bis = new BufferedInputStream( | BufferedInputStream bis = new BufferedInputStream( | ||||
| new FileInputStream(cachefile)); | |||||
| Files.newInputStream(cachefile.toPath())); | |||||
| cache.load(bis); | cache.load(bis); | ||||
| bis.close(); | bis.close(); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| @@ -159,7 +160,7 @@ public class PropertiesfileCache implements Cache { | |||||
| if ((cachefile != null) && cache.propertyNames().hasMoreElements()) { | if ((cachefile != null) && cache.propertyNames().hasMoreElements()) { | ||||
| try { | try { | ||||
| BufferedOutputStream bos = new BufferedOutputStream( | BufferedOutputStream bos = new BufferedOutputStream( | ||||
| new FileOutputStream(cachefile)); | |||||
| Files.newOutputStream(cachefile.toPath())); | |||||
| cache.store(bos, null); | cache.store(bos, null); | ||||
| bos.flush(); | bos.flush(); | ||||
| bos.close(); | bos.close(); | ||||
| @@ -20,9 +20,9 @@ package org.apache.tools.ant.util; | |||||
| import java.io.BufferedInputStream; | import java.io.BufferedInputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.nio.file.Files; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.ProjectComponent; | import org.apache.tools.ant.ProjectComponent; | ||||
| @@ -119,7 +119,7 @@ public class ConcatFileInputStream extends InputStream { | |||||
| log("Opening " + file[index], Project.MSG_VERBOSE); | log("Opening " + file[index], Project.MSG_VERBOSE); | ||||
| try { | try { | ||||
| currentStream = new BufferedInputStream( | currentStream = new BufferedInputStream( | ||||
| new FileInputStream(file[index])); | |||||
| Files.newInputStream(file[index].toPath())); | |||||
| } catch (IOException eyeOhEx) { | } catch (IOException eyeOhEx) { | ||||
| log("Failed to open " + file[index], Project.MSG_ERR); | log("Failed to open " + file[index], Project.MSG_ERR); | ||||
| throw eyeOhEx; | throw eyeOhEx; | ||||
| @@ -31,6 +31,9 @@ import java.net.MalformedURLException; | |||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.net.URLConnection; | import java.net.URLConnection; | ||||
| import java.nio.channels.Channel; | import java.nio.channels.Channel; | ||||
| import java.nio.file.Files; | |||||
| import java.nio.file.Path; | |||||
| import java.nio.file.StandardOpenOption; | |||||
| import java.text.DecimalFormat; | import java.text.DecimalFormat; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Arrays; | import java.util.Arrays; | ||||
| @@ -1707,4 +1710,20 @@ public class FileUtils { | |||||
| close(is); | close(is); | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Opens a new OutputStream for the given Path. | |||||
| * @param path the path of the file | |||||
| * @param whether to append to or a replace an existing file | |||||
| * @return a stream ready to write to the file | |||||
| * @since Ant 1.10.2 | |||||
| */ | |||||
| public static OutputStream newOutputStream(Path path, boolean append) throws IOException { | |||||
| if (append) { | |||||
| return Files.newOutputStream(path, StandardOpenOption.CREATE, StandardOpenOption.APPEND, | |||||
| StandardOpenOption.WRITE); | |||||
| } else { | |||||
| return Files.newOutputStream(path); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -20,7 +20,6 @@ package org.apache.tools.ant.util; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.ByteArrayInputStream; | import java.io.ByteArrayInputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| @@ -28,6 +27,7 @@ import java.io.OutputStream; | |||||
| import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
| import java.io.PrintStream; | import java.io.PrintStream; | ||||
| import java.io.PushbackReader; | import java.io.PushbackReader; | ||||
| import java.nio.file.Files; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| @@ -250,7 +250,7 @@ public class LayoutPreservingProperties extends Properties { | |||||
| * @param dest the file to write to | * @param dest the file to write to | ||||
| */ | */ | ||||
| public void saveAs(final File dest) throws IOException { | public void saveAs(final File dest) throws IOException { | ||||
| final FileOutputStream fos = new FileOutputStream(dest); | |||||
| final OutputStream fos = Files.newOutputStream(dest.toPath()); | |||||
| store(fos, null); | store(fos, null); | ||||
| fos.close(); | fos.close(); | ||||
| } | } | ||||
| @@ -18,9 +18,9 @@ | |||||
| package org.apache.tools.ant.util; | package org.apache.tools.ant.util; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| /** | /** | ||||
| * Class that delays opening the output file until the first bytes | * Class that delays opening the output file until the first bytes | ||||
| @@ -31,7 +31,7 @@ import java.io.OutputStream; | |||||
| */ | */ | ||||
| public class LazyFileOutputStream extends OutputStream { | public class LazyFileOutputStream extends OutputStream { | ||||
| private FileOutputStream fos; | |||||
| private OutputStream fos; | |||||
| private File file; | private File file; | ||||
| private boolean append; | private boolean append; | ||||
| private boolean alwaysCreate; | private boolean alwaysCreate; | ||||
| @@ -155,7 +155,7 @@ public class LazyFileOutputStream extends OutputStream { | |||||
| } | } | ||||
| if (!opened) { | if (!opened) { | ||||
| fos = new FileOutputStream(file.getAbsolutePath(), append); | |||||
| fos = FileUtils.newOutputStream(file.toPath(), append); | |||||
| opened = true; | opened = true; | ||||
| } | } | ||||
| } | } | ||||
| @@ -21,8 +21,6 @@ import java.io.BufferedInputStream; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.BufferedWriter; | import java.io.BufferedWriter; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileOutputStream; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| @@ -30,6 +28,7 @@ import java.io.OutputStream; | |||||
| import java.io.OutputStreamWriter; | import java.io.OutputStreamWriter; | ||||
| import java.io.Reader; | import java.io.Reader; | ||||
| import java.nio.channels.FileChannel; | import java.nio.channels.FileChannel; | ||||
| import java.nio.file.StandardOpenOption; | |||||
| import java.util.Arrays; | import java.util.Arrays; | ||||
| import java.util.Vector; | import java.util.Vector; | ||||
| @@ -777,17 +776,13 @@ public class ResourceUtils { | |||||
| + " for " + destFile); | + " for " + destFile); | ||||
| } | } | ||||
| FileInputStream in = null; | |||||
| FileOutputStream out = null; | |||||
| FileChannel srcChannel = null; | FileChannel srcChannel = null; | ||||
| FileChannel destChannel = null; | FileChannel destChannel = null; | ||||
| try { | try { | ||||
| in = new FileInputStream(sourceFile); | |||||
| out = new FileOutputStream(destFile); | |||||
| srcChannel = in.getChannel(); | |||||
| destChannel = out.getChannel(); | |||||
| srcChannel = FileChannel.open(sourceFile.toPath(), StandardOpenOption.READ); | |||||
| destChannel = FileChannel.open(destFile.toPath(), StandardOpenOption.CREATE, | |||||
| StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE); | |||||
| long position = 0; | long position = 0; | ||||
| final long count = srcChannel.size(); | final long count = srcChannel.size(); | ||||
| @@ -799,8 +794,6 @@ public class ResourceUtils { | |||||
| } finally { | } finally { | ||||
| FileUtils.close(srcChannel); | FileUtils.close(srcChannel); | ||||
| FileUtils.close(destChannel); | FileUtils.close(destChannel); | ||||
| FileUtils.close(out); | |||||
| FileUtils.close(in); | |||||
| } | } | ||||
| } | } | ||||
| @@ -19,13 +19,12 @@ package org.apache.tools.ant.util; | |||||
| import java.io.BufferedReader; | import java.io.BufferedReader; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileInputStream; | |||||
| import java.io.FileNotFoundException; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
| import java.io.Reader; | import java.io.Reader; | ||||
| import java.nio.charset.Charset; | import java.nio.charset.Charset; | ||||
| import java.nio.file.Files; | |||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -233,8 +232,8 @@ public abstract class ScriptRunnerBase { | |||||
| InputStream in = null; | InputStream in = null; | ||||
| try { | try { | ||||
| in = new FileInputStream(file); | |||||
| } catch (FileNotFoundException e) { | |||||
| in = Files.newInputStream(file.toPath()); | |||||
| } catch (IOException e) { | |||||
| //this can only happen if the file got deleted a short moment ago | //this can only happen if the file got deleted a short moment ago | ||||
| throw new BuildException("file " + filename + " not found."); | throw new BuildException("file " + filename + " not found."); | ||||
| } | } | ||||
| @@ -31,12 +31,12 @@ import static org.apache.tools.zip.ZipShort.putShort; | |||||
| import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileOutputStream; | |||||
| import java.io.FilterOutputStream; | import java.io.FilterOutputStream; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.OutputStream; | import java.io.OutputStream; | ||||
| import java.io.RandomAccessFile; | import java.io.RandomAccessFile; | ||||
| import java.nio.ByteBuffer; | import java.nio.ByteBuffer; | ||||
| import java.nio.file.Files; | |||||
| import java.util.Calendar; | import java.util.Calendar; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| @@ -355,7 +355,7 @@ public class ZipOutputStream extends FilterOutputStream { | |||||
| } | } | ||||
| _raf = null; | _raf = null; | ||||
| } | } | ||||
| out = new FileOutputStream(file); | |||||
| out = Files.newOutputStream(file.toPath()); | |||||
| } | } | ||||
| raf = _raf; | raf = _raf; | ||||
| } | } | ||||