The Data Mining Forum                             open-source data mining software data mining conferences Data Science for Social and Behavioral Analytics DSSBA 2022 data science journal
IMPORTANT: This is the old Data Mining forum.
I keep it online so that you can read the old messages.

Please post your new messages in the new forum: https://forum2.philippe-fournier-viger.com/index.php
 
GoKrimp ERROR MESSAGE = java.lang.StringIndexOutOfBoundsException: String index out of range: 0
Posted by: vrodriguezf
Date: January 09, 2019 02:43AM

Hi,

I am getting this error when executing the algorithm GoKrimp from the command line:

An error while trying to run the algorithm.
ERROR MESSAGE = java.lang.StringIndexOutOfBoundsException: String index out of range: 0
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at ca.pfv.spmf.algorithms.sequentialpatterns.goKrimp.DataReader.readData_SPMF(DataReader.java:113)
at ca.pfv.spmf.algorithmmanager.descriptions.DescriptionAlgoGoKrimp.runAlgorithm(DescriptionAlgoGoKrimp.java:75)
at ca.pfv.spmf.gui.CommandProcessor.runAlgorithm(CommandProcessor.java:244)
at ca.pfv.spmf.gui.Main.processCommandLineArguments(Main.java:130)
at ca.pfv.spmf.gui.Main.main(Main.java:56)


This is the input file I am using, in case you want to reproduce the error:
link to the input file

I am thinking that the reason maybe that the sequences are very long. Does that make sense?

Best!

Options: ReplyQuote
Re: GoKrimp ERROR MESSAGE = java.lang.StringIndexOutOfBoundsException: String index out of range: 0
Date: January 09, 2019 05:06PM

Hi,

I have checked. The issue is that there are two empty lines at the end of the file "inputSPMF.txt". Normally, it should not cause a problem but there was a bug in the code such that if there is some empty line, it would crash.

For now, you can just delete the empty lines and it will work. In the next release of SPMF the bug will have been fixed. ;-)

Thanks for reporting it.

Options: ReplyQuote
Re: GoKrimp ERROR MESSAGE = java.lang.StringIndexOutOfBoundsException: String index out of range: 0
Posted by: vrodriguezf
Date: January 10, 2019 01:13AM

Hi,

Many thanks for your help and for this wonderful framework! winking smiley

Options: ReplyQuote
Re: GoKrimp ERROR MESSAGE = java.lang.StringIndexOutOfBoundsException: String index out of range: 0
Date: January 10, 2019 07:02AM

You are welcome. Thanks for using it and glad it is useful ;-)

Options: ReplyQuote
Re: GoKrimp ERROR MESSAGE = java.lang.StringIndexOutOfBoundsException: String index out of range: 0
Posted by: delonbest
Date: March 12, 2020 10:39PM

When using the Java substring() method, a subset of the character sequence can be extracted from a string. The substring index must be any value from 0 to the length of a string. The java.lang.StringIndexOutOfBoundsException thrown by String methods to indicate that the beginIndex is negative , or endIndex is larger than the length of this String object, or beginIndex is larger than endIndex.

How to solve the StringIndexOutOfBoundsException


Check the length of the string before using substring()
Exception handling using try...catch.

Options: ReplyQuote
Re: GoKrimp ERROR MESSAGE = java.lang.StringIndexOutOfBoundsException: String index out of range: 0
Date: March 16, 2020 09:22AM

Good explanation!

Options: ReplyQuote


This forum is powered by Phorum and provided by P. Fournier-Viger (© 2012).
Terms of use.