use indexOf(char) instead of indexOf(String) where possible; replace one more StringBuffer with StringBuilder - bug 63805

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1874262 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Axel Howind 2020-02-20 15:51:17 +00:00
parent 09d55c7832
commit 842e71a3d7
10 changed files with 10 additions and 10 deletions

View File

@ -346,7 +346,7 @@ public class ToCSV {
// Simply replace the .xls or .xlsx file extension with .csv
destinationFilename = excelFile.getName();
destinationFilename = destinationFilename.substring(
0, destinationFilename.lastIndexOf(".")) +
0, destinationFilename.lastIndexOf('.')) +
ToCSV.CSV_FILE_EXTENSION;
// Save the CSV file away using the newly constricted file name

View File

@ -47,7 +47,7 @@ public class CellTextFormatter extends CellFormatter {
textPos = new int[numPlaces[0]];
int pos = desc.length() - 1;
for (int i = 0; i < textPos.length; i++) {
textPos[i] = desc.lastIndexOf("\u0000", pos);
textPos[i] = desc.lastIndexOf('\u0000', pos);
pos = textPos[i] - 1;
}
}

View File

@ -122,7 +122,7 @@ public class CellRangeAddress extends CellRangeAddressBase {
* column range (e.g. "C:F")
*/
public static CellRangeAddress valueOf(String ref) {
int sep = ref.indexOf(":");
int sep = ref.indexOf(':');
CellReference a;
CellReference b;
if (sep == -1) {

View File

@ -111,7 +111,7 @@ public final class ContentTypes {
public static final String EXTENSION_XML = "xml";
public static String getContentTypeFromFileExtension(String filename) {
String extension = filename.substring(filename.lastIndexOf(".") + 1)
String extension = filename.substring(filename.lastIndexOf('.') + 1)
.toLowerCase(Locale.ROOT);
if (extension.equals(EXTENSION_JPG_1)
|| extension.equals(EXTENSION_JPG_2))

View File

@ -517,7 +517,7 @@ public abstract class OPCPackage implements RelationshipSource, Closeable {
+ filename);
} catch (InvalidFormatException e) {
String partName = "/docProps/thumbnail" +
filename.substring(filename.lastIndexOf(".") + 1);
filename.substring(filename.lastIndexOf('.') + 1);
try {
thumbnailPartName = PackagingURIHelper.createPartName(partName);
} catch (InvalidFormatException e2) {

View File

@ -422,7 +422,7 @@ public final class PackagePartName implements Comparable<PackagePartName> {
public String getExtension() {
String fragment = this.partNameURI.getPath();
if (fragment.length() > 0) {
int i = fragment.lastIndexOf(".");
int i = fragment.lastIndexOf('.');
if (i > -1) {
return fragment.substring(i + 1);
}

View File

@ -193,7 +193,7 @@ public final class PackagingURIHelper {
*/
public static String getFilenameWithoutExtension(URI uri) {
String filename = getFilename(uri);
int dotIndex = filename.lastIndexOf(".");
int dotIndex = filename.lastIndexOf('.');
if (dotIndex == -1)
return filename;
return filename.substring(0, dotIndex);

View File

@ -22,7 +22,7 @@ public class Util {
public static int countLines(String str) {
int lines = 1;
int pos = 0;
while ((pos = str.indexOf("\n", pos) + 1) != 0) {
while ((pos = str.indexOf('\n', pos) + 1) != 0) {
lines++;
}
return lines;

View File

@ -916,7 +916,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
assertEquals(text, cell.getStringCellValue());
// Now add a 2nd, and check again
int fontAt = text.indexOf("\n", 6);
int fontAt = text.indexOf('\n', 6);
cell.getRichStringCellValue().applyFont(10, fontAt + 1, font2);
assertEquals(text, cell.getStringCellValue());

View File

@ -47,7 +47,7 @@ public final class TestBug46610 {
private static String runExtract(String sampleName) throws Exception {
HWPFDocument doc = HWPFTestDataSamples.openSampleFile(sampleName);
StringBuffer out = new StringBuffer();
StringBuilder out = new StringBuilder();
Range globalRange = doc.getRange();
for (int i = 0; i < globalRange.numParagraphs(); i++) {