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