@@ -578,11 +578,7 @@ public class Checksum extends MatchingTask implements Condition { | |||||
private String createDigestString(byte[] fileDigest) { | private String createDigestString(byte[] fileDigest) { | ||||
StringBuilder checksumSb = new StringBuilder(); | StringBuilder checksumSb = new StringBuilder(); | ||||
for (byte digestByte : fileDigest) { | for (byte digestByte : fileDigest) { | ||||
String hexStr = Integer.toHexString(BYTE_MASK & digestByte); | |||||
if (hexStr.length() < 2) { | |||||
checksumSb.append('0'); | |||||
} | |||||
checksumSb.append(hexStr); | |||||
checksumSb.append(String.format("%02x", BYTE_MASK & digestByte)); | |||||
} | } | ||||
return checksumSb.toString(); | return checksumSb.toString(); | ||||
} | } | ||||
@@ -76,9 +76,8 @@ public class ManifestClassPath extends Task { | |||||
final FileUtils fileUtils = FileUtils.getFileUtils(); | final FileUtils fileUtils = FileUtils.getFileUtils(); | ||||
dir = fileUtils.normalize(dir.getAbsolutePath()); | dir = fileUtils.normalize(dir.getAbsolutePath()); | ||||
String[] elements = path.list(); | |||||
StringBuilder buffer = new StringBuilder(); | StringBuilder buffer = new StringBuilder(); | ||||
for (String element : elements) { | |||||
for (String element : path.list()) { | |||||
// Normalize the current file | // Normalize the current file | ||||
File pathEntry = new File(element); | File pathEntry = new File(element); | ||||
String fullPath = pathEntry.getAbsolutePath(); | String fullPath = pathEntry.getAbsolutePath(); | ||||
@@ -906,7 +906,8 @@ public class SQLExec extends JDBCTask { | |||||
} | } | ||||
private String maybeQuote(String s) { | private String maybeQuote(String s) { | ||||
if (csvQuoteChar == null || s == null || (!forceCsvQuoteChar && !s.contains(csvColumnSep) && !s.contains(csvQuoteChar))) { | |||||
if (csvQuoteChar == null || s == null | |||||
|| (!forceCsvQuoteChar && !s.contains(csvColumnSep) && !s.contains(csvQuoteChar))) { | |||||
return s; | return s; | ||||
} | } | ||||
StringBuilder sb = new StringBuilder(csvQuoteChar); | StringBuilder sb = new StringBuilder(csvQuoteChar); | ||||
@@ -34,7 +34,6 @@ import org.apache.tools.ant.types.Commandline; | |||||
import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
import org.apache.tools.ant.types.Reference; | import org.apache.tools.ant.types.Reference; | ||||
import org.apache.tools.ant.util.StringUtils; | |||||
import org.apache.tools.ant.util.facade.FacadeTaskHelper; | import org.apache.tools.ant.util.facade.FacadeTaskHelper; | ||||
import org.apache.tools.ant.util.facade.ImplementationSpecificArgument; | import org.apache.tools.ant.util.facade.ImplementationSpecificArgument; | ||||
@@ -484,11 +483,10 @@ public class Javah extends Task { | |||||
if (c.length > 1) { | if (c.length > 1) { | ||||
message.append("es"); | message.append("es"); | ||||
} | } | ||||
message.append(" to be compiled:"); | |||||
message.append(StringUtils.LINE_SEP); | |||||
message.append(String.format(" to be compiled:%n")); | |||||
for (String element : c) { | for (String element : c) { | ||||
cmd.createArgument().setValue(element); | cmd.createArgument().setValue(element); | ||||
message.append(" ").append(element).append(StringUtils.LINE_SEP); | |||||
message.append(String.format(" %s%n", element)); | |||||
} | } | ||||
log(message.toString(), Project.MSG_VERBOSE); | log(message.toString(), Project.MSG_VERBOSE); | ||||
} | } | ||||
@@ -278,7 +278,7 @@ public class RExecTask extends Task { | |||||
} else { | } else { | ||||
Calendar endTime = Calendar.getInstance(); | Calendar endTime = Calendar.getInstance(); | ||||
endTime.add(Calendar.SECOND, timeout); | endTime.add(Calendar.SECOND, timeout); | ||||
int read = 0; | |||||
int read = 0; | |||||
while (read != -1) { | while (read != -1) { | ||||
while (Calendar.getInstance().before(endTime) && is.available() == 0) { | while (Calendar.getInstance().before(endTime) && is.available() == 0) { | ||||
Thread.sleep(PAUSE_TIME); | Thread.sleep(PAUSE_TIME); | ||||
@@ -289,7 +289,7 @@ public class RExecTask extends Task { | |||||
"Response timed-out waiting for EOF", | "Response timed-out waiting for EOF", | ||||
getLocation()); | getLocation()); | ||||
} | } | ||||
read = is.read(); | |||||
read = is.read(); | |||||
if (read != -1) { | if (read != -1) { | ||||
char c = (char) read; | char c = (char) read; | ||||
sb.append(c); | sb.append(c); | ||||
@@ -166,11 +166,7 @@ public class DigestAlgorithm implements Algorithm { | |||||
} | } | ||||
StringBuilder checksumSb = new StringBuilder(); | StringBuilder checksumSb = new StringBuilder(); | ||||
for (byte digestByte : messageDigest.digest()) { | for (byte digestByte : messageDigest.digest()) { | ||||
String hexStr = Integer.toHexString(BYTE_MASK & digestByte); | |||||
if (hexStr.length() < 2) { | |||||
checksumSb.append('0'); | |||||
} | |||||
checksumSb.append(hexStr); | |||||
checksumSb.append(String.format("%02x", BYTE_MASK & digestByte)); | |||||
} | } | ||||
return checksumSb.toString(); | return checksumSb.toString(); | ||||
} catch (IOException ignored) { | } catch (IOException ignored) { | ||||
@@ -1073,15 +1073,14 @@ public class FileUtils { | |||||
} | } | ||||
final char[] buffer = new char[bufferSize]; | final char[] buffer = new char[bufferSize]; | ||||
int bufferLength = 0; | int bufferLength = 0; | ||||
StringBuilder textBuffer = null; | |||||
StringBuilder textBuffer = new StringBuilder(); | |||||
while (bufferLength != -1) { | while (bufferLength != -1) { | ||||
bufferLength = rdr.read(buffer); | bufferLength = rdr.read(buffer); | ||||
if (bufferLength > 0) { | if (bufferLength > 0) { | ||||
textBuffer = (textBuffer == null) ? new StringBuilder() : textBuffer; | |||||
textBuffer.append(buffer, 0, bufferLength); | textBuffer.append(buffer, 0, bufferLength); | ||||
} | } | ||||
} | } | ||||
return (textBuffer == null) ? null : textBuffer.toString(); | |||||
return (textBuffer.length() == 0) ? null : textBuffer.toString(); | |||||
} | } | ||||
/** | /** | ||||
@@ -38,12 +38,7 @@ public class Native2AsciiUtils { | |||||
if (c <= MAX_ASCII) { | if (c <= MAX_ASCII) { | ||||
sb.append(c); | sb.append(c); | ||||
} else { | } else { | ||||
sb.append("\\u"); | |||||
String encoded = Integer.toHexString(c); | |||||
for (int i = encoded.length(); i < 4; i++) { | |||||
sb.append("0"); | |||||
} | |||||
sb.append(encoded); | |||||
sb.append(String.format("\\u%04x", (int) c)); | |||||
} | } | ||||
} | } | ||||
return sb.toString(); | return sb.toString(); | ||||
@@ -62,8 +62,7 @@ public class TarUtils { | |||||
} | } | ||||
public String decode(final byte[] buffer) { | public String decode(final byte[] buffer) { | ||||
final int length = buffer.length; | |||||
final StringBuilder result = new StringBuilder(length); | |||||
final StringBuilder result = new StringBuilder(buffer.length); | |||||
for (final byte b : buffer) { | for (final byte b : buffer) { | ||||
if (b == 0) { // Trailing null | if (b == 0) { // Trailing null | ||||