I'm trying to use com.google.common.base.Splitter as follows
Iterable<String> segs = Splitter.on("/").split("one/two/three/four/five"); for (String seg : segs) { System.out.println(seg); }
However, I'm seeing the following exception:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Platform.precomputeCharMatcher(Lcom/google/common/base/CharMatcher;)Lcom/google/common/base/CharMatcher; at com.google.common.base.CharMatcher.precomputed(CharMatcher.java:664) at com.google.common.base.CharMatcher.<clinit>(CharMatcher.java:71) at com.google.common.base.Splitter.<init>(Splitter.java:107) at com.google.common.base.Splitter.on(Splitter.java:171) at Test.main(Test.java:30)
Does anyone have any idea what I'm doing wrong here?
I encountered the same problem. It turned out that I used a older version of guava. Go to this website:https://code.google.com/p/guava-libraries/, and download a newer version.
By the way,google-collections was renamed to Guava.
Use the below dependency to fix the issue
To add a dependency on Guava using Maven, use the following:
<dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>19.0</version> </dependency>
To add a dependency using Gradle:
dependencies { compile 'com.google.guava:guava:19.0' }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With