mirror of https://github.com/apache/poi.git
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:
parent
09d55c7832
commit
842e71a3d7
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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++) {
|
||||
|
|
Loading…
Reference in New Issue