java.lang.StringIndexOutOfBoundsException: String index out of range: 1

Coderanch | S Babs | 1 decade ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    replaceAll method of String class

    Coderanch | 1 decade ago | S Babs
    java.lang.StringIndexOutOfBoundsException: String index out of range: 1
  2. 0

    Bug ID: JDK-4689750 String.ReplaceAll() gives java.lang.StringIndexOutOfBoundsException

    java.com | 7 months ago
    java.lang.StringIndexOutOfBoundsException: String index out of range: 1
  3. 0

    Clover-for-Grails generates an exception when using the -clover.view option on the Grails command line. According to Nick's assessment so far, this is a Windows-specific problem. See output below: {noformat} C:\grails-1.2.1\samples\petclinic>grails test-app -clover.on -clover.view Welcome to Grails 1.2.1 - http://grails.org/ Licensed under Apache Standard License 2.0 Grails home is set to: C:\grails-1.2.1 Base Directory: C:\grails-1.2.1\samples\petclinic Resolving dependencies... Dependencies resolved in 2641ms. Running script C:\grails-1.2.1\scripts\TestApp.groovy Environment set to test Clover: Using config: [on:true, view:true] Using clover license path: C:\Documents and Settings\Giles Gaskell\.grails\1.2.1\projects\petclinic\plugins\clover-0.2\grails-app\conf\clover\clover-evaluation. license [clover-env] Loading clover.xml: jar:file:/C:/Documents%20and%20Settings/Giles%20Gaskell/.ivy2/cache/com.cenqua.clover/clover/jars/clover-3.0.0-m3.jar!/clover.x ml Using default clover-setup configuration. Clover: directories: [src/java, src/groovy, test, grails-app] includes: [**/*.groovy, **/*.java] excludes [**/conf/**, **/plugins/**] [clover-setup] Clover Version 3.0.0-m3, built on February 26 2010 (build-780) [clover-setup] Loaded from: C:\Documents and Settings\Giles Gaskell\.ivy2\cache\com.cenqua.clover\clover\jars\clover-3.0.0-m3.jar [clover-setup] Clover Evaluation License registered to Clover Grails Plugin. [clover-setup] You have 23 day(s) before your license expires. [clover-setup] Clover is enabled with initstring 'C:\Documents and Settings\Giles Gaskell\.grails\1.2.1\projects\petclinic\clover\db\clover.db' Clover: Forcing a clean to ensure Clover instrumentation occurs. Disable by setting: clover.forceClean=false [delete] Deleting directory C:\grails-1.2.1\samples\petclinic\target\classes [delete] Deleting directory C:\grails-1.2.1\samples\petclinic\target\test-classes [delete] Deleting directory C:\Documents and Settings\Giles Gaskell\.grails\1.2.1\projects\petclinic\clover Clover: Compile start. [mkdir] Created dir: C:\grails-1.2.1\samples\petclinic\target\classes [groovyc] Compiling 2 source files to C:\grails-1.2.1\samples\petclinic\target\classes [clover-setup] Creating new database at 'C:\Documents and Settings\Giles Gaskell\.grails\1.2.1\projects\petclinic\clover\db\clover.db'. [groovyc] Compiling 17 source files to C:\grails-1.2.1\samples\petclinic\target\classes [clover-setup] Creating new database at 'C:\Documents and Settings\Giles Gaskell\.grails\1.2.1\projects\petclinic\clover\db\clover.db'. [mkdir] Created dir: C:\grails-1.2.1\samples\petclinic\target\test-reports\html [mkdir] Created dir: C:\grails-1.2.1\samples\petclinic\target\test-reports\plain Starting unit test phase ... [mkdir] Created dir: C:\grails-1.2.1\samples\petclinic\target\test-classes\unit [groovyc] Compiling 1 source file to C:\grails-1.2.1\samples\petclinic\target\test-classes\unit [clover-setup] Updating existing database at 'C:\Documents and Settings\Giles Gaskell\.grails\1.2.1\projects\petclinic\clover\db\clover.db'. ------------------------------------------------------- Running 1 unit test... Running test org.grails.samples.OwnerControllerTests...PASSED Tests Completed in 2015ms ... ------------------------------------------------------- Tests passed: 6 Tests failed: 0 ------------------------------------------------------- Starting integration test phase ... [copy] Copying 1 file to C:\grails-1.2.1\samples\petclinic\target\test-classes\integration [copy] Copying 1 file to C:\grails-1.2.1\samples\petclinic\target\test-classes [copy] Copied 3 empty directories to 2 empty directories under C:\grails-1.2.1\samples\petclinic\target\test-classes Clover: Compile start. [groovyc] Compiling 1 source file to C:\grails-1.2.1\samples\petclinic\target\classes [clover-setup] Updating existing database at 'C:\Documents and Settings\Giles Gaskell\.grails\1.2.1\projects\petclinic\clover\db\clover.db'. [copy] Copying 1 file to C:\grails-1.2.1\samples\petclinic\target\classes Clover: Compile start. [groovyc] Compiling 1 source file to C:\grails-1.2.1\samples\petclinic\target\classes [clover-setup] Updating existing database at 'C:\Documents and Settings\Giles Gaskell\.grails\1.2.1\projects\petclinic\clover\db\clover.db'. [junitreport] Processing C:\grails-1.2.1\samples\petclinic\target\test-reports\TESTS-TestSuites.xml to C:\DOCUME~1\GILESG~1\LOCALS~1\Temp\null1750708552 [junitreport] Loading stylesheet jar:file:/C:/Documents%20and%20Settings/Giles%20Gaskell/.ivy2/cache/org.apache.ant/ant-junit/jars/ant-junit-1.7.1.jar!/org/apac he/tools/ant/taskdefs/optional/junit/xsl/junit-frames.xsl [junitreport] Transform time: 735ms [junitreport] Deleting: C:\DOCUME~1\GILESG~1\LOCALS~1\Temp\null1750708552 Tests PASSED - view reports in target\test-reports Clover: Tests ended [clover-historypoint] Clover Version 3.0.0-m3, built on February 26 2010 (build-780) [clover-historypoint] Loaded from: C:\Documents and Settings\Giles Gaskell\.ivy2\cache\com.cenqua.clover\clover\jars\clover-3.0.0-m3.jar [clover-historypoint] Clover Evaluation License registered to Clover Grails Plugin. [clover-historypoint] You have 23 day(s) before your license expires. [clover-historypoint] Writing report to 'C:\grails-1.2.1\samples\petclinic\.cloverhistory\clover-20100305112533.xml.gz' [clover-html-report] Clover Version 3.0.0-m3, built on February 26 2010 (build-780) [clover-html-report] Loaded from: C:\Documents and Settings\Giles Gaskell\.ivy2\cache\com.cenqua.clover\clover\jars\clover-3.0.0-m3.jar [clover-html-report] Clover Evaluation License registered to Clover Grails Plugin. [clover-html-report] You have 23 day(s) before your license expires. [clover-html-report] Not overwriting existing history point 'C:\grails-1.2.1\samples\petclinic\.cloverhistory\clover-20100305112533.xml.gz'. To force, set overw rite="true". [clover-html-report] Loading coverage database from: 'C:\Documents and Settings\Giles Gaskell\.grails\1.2.1\projects\petclinic\clover\db\clover.db' [clover-html-report] Loading historical coverage data from: 'C:\grails-1.2.1\samples\petclinic\.cloverhistory' [clover-html-report] Writing HTML report to 'C:\grails-1.2.1\samples\petclinic\build\clover\report' [clover-html-report] Done. Processed 1 packages in 3047ms (3047ms per package). [clover-html-report] Writing historical report to 'C:\grails-1.2.1\samples\petclinic\build\clover\report' [clover-html-report] Read 3 history points. [clover-html-report] using movers interval of 18 hours [clover-html-report] using movers interval of 18 hours [clover-html-report] Writing JSON historical-data to: C:\grails-1.2.1\samples\petclinic\build\clover\report\historical-json.js [clover-html-report] Done. Error executing script TestApp: java.lang.StringIndexOutOfBoundsException: String index out of range: 1 gant.TargetExecutionException: java.lang.StringIndexOutOfBoundsException: String index out of range: 1 at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:331) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy) at gant.Gant.withBuildListeners(Gant.groovy:344) at gant.Gant.this$2$withBuildListeners(Gant.groovy) at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) at gant.Gant.dispatch(Gant.groovy:334) at gant.Gant.this$2$dispatch(Gant.groovy) at gant.Gant.invokeMethod(Gant.groovy) at gant.Gant.processTargets(Gant.groovy:495) at gant.Gant.processTargets(Gant.groovy:480) Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 1 at java.lang.String.charAt(String.java:687) at java.util.regex.Matcher.appendReplacement(Matcher.java:703) at java.util.regex.Matcher.replaceAll(Matcher.java:813) at java.lang.String.replaceAll(String.java:2190) at _Events.launchReport(_Events.groovy:138) at _Events$_run_closure6.doCall(_Events.groovy:108) at _GrailsEvents_groovy$_run_closure5.doCall(_GrailsEvents_groovy:58) at _GrailsEvents_groovy$_run_closure5.call(_GrailsEvents_groovy) at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:214) at TestApp$_run_closure1.doCall(TestApp.groovy:102) at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324) ... 10 more Error executing script TestApp: java.lang.StringIndexOutOfBoundsException: String index out of range: 1 Application context shutting down... Application context shutdown. {noformat}

    Atlassian JIRA | 7 years ago | Giles Gaskell [Atlassian]
    gant.TargetExecutionException: java.lang.StringIndexOutOfBoundsException: String index out of range: 1
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    jberkel/android-app fails with java.lang.StringIndexOutOfBoundsException: String index out of range: 1

    GitHub | 5 years ago | glenviewjeff
    java.lang.StringIndexOutOfBoundsException: String index out of range: 1
  6. 0

    [develop_2.0] String index out of exception in android-java template

    GitHub | 2 years ago | cantecim
    java.lang.StringIndexOutOfBoundsException: String index out of range: 1

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.StringIndexOutOfBoundsException

      String index out of range: 1

      at java.lang.String.charAt()
    2. Java RT
      String.replaceAll
      1. java.lang.String.charAt(String.java:455)
      2. java.util.regex.Matcher.appendReplacement(Matcher.java:532)
      3. java.util.regex.Matcher.replaceAll(Matcher.java:636)
      4. java.lang.String.replaceAll(String.java:1706)
      4 frames
    3. Unknown
      ReplaceString.main
      1. ReplaceString.main(ReplaceString.java:6)
      1 frame