Skip to content

Commit 2b19524

Browse files
johnmayegonw
authored andcommitted
Replace Guava CharStreams with normal JDK 1.8 streams
1 parent 80aee43 commit 2b19524

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

legacy/src/test/java/org/openscience/cdk/smiles/smarts/parser/RecursiveTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
*/
1919
package org.openscience.cdk.smiles.smarts.parser;
2020

21+
import java.io.BufferedReader;
2122
import java.io.InputStream;
2223
import java.io.InputStreamReader;
24+
import java.util.stream.Collectors;
2325

24-
import com.google.common.io.CharStreams;
2526
import org.junit.Assert;
2627
import org.junit.Test;
2728
import org.junit.experimental.categories.Category;
@@ -456,7 +457,8 @@ public void testBasicAmineOnDrugs() throws Exception {
456457

457458
int nmatch = 0;
458459
int nmol = 0;
459-
for (String smi : CharStreams.readLines(new InputStreamReader(ins))) {
460+
for (String smi : new BufferedReader(new InputStreamReader(ins)).lines()
461+
.collect(Collectors.toList())) {
460462
IAtomContainer container = sp.parseSmiles(smi.split("\t")[0]);
461463
if (sqt.matches(container)) {
462464
nmatch++;

storage/ioformats/src/main/java/org/openscience/cdk/io/FormatFactory.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,26 @@
1919
*/
2020
package org.openscience.cdk.io;
2121

22+
import org.openscience.cdk.io.formats.IChemFormat;
23+
import org.openscience.cdk.io.formats.IChemFormatMatcher;
24+
import org.openscience.cdk.io.formats.IChemFormatMatcher.MatchResult;
25+
import org.openscience.cdk.io.formats.XYZFormat;
26+
import org.openscience.cdk.tools.ILoggingTool;
27+
import org.openscience.cdk.tools.LoggingToolFactory;
28+
2229
import java.io.BufferedReader;
2330
import java.io.CharArrayReader;
2431
import java.io.IOException;
2532
import java.io.InputStream;
2633
import java.io.Reader;
2734
import java.io.StringReader;
2835
import java.util.ArrayList;
29-
import java.util.Collections;
3036
import java.util.List;
3137
import java.util.ServiceLoader;
3238
import java.util.Set;
3339
import java.util.StringTokenizer;
3440
import java.util.TreeSet;
35-
36-
import org.openscience.cdk.io.formats.IChemFormat;
37-
import org.openscience.cdk.io.formats.IChemFormatMatcher;
38-
import org.openscience.cdk.io.formats.IChemFormatMatcher.MatchResult;
39-
import org.openscience.cdk.io.formats.XYZFormat;
40-
import org.openscience.cdk.tools.ILoggingTool;
41-
import org.openscience.cdk.tools.LoggingToolFactory;
42-
43-
import com.google.common.io.CharStreams;
41+
import java.util.stream.Collectors;
4442

4543
/**
4644
* A factory for recognizing chemical file formats. Formats
@@ -177,7 +175,7 @@ public IChemFormat guessFormat(InputStream input) throws IOException {
177175

178176
private IChemFormat getMatchResult( BufferedReader buffer) throws IOException{
179177
/* Search file for a line containing an identifying keyword */
180-
List<String> lines = Collections.unmodifiableList(CharStreams.readLines(buffer));
178+
List<String> lines = buffer.lines().collect(Collectors.toList());
181179
Set<MatchResult> results = new TreeSet<MatchResult>();
182180

183181
for (IChemFormatMatcher format : formats) {

storage/ioformats/src/test/java/org/openscience/cdk/io/formats/ChemFormatMatcherTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
import java.io.StringReader;
2828
import java.util.Arrays;
2929
import java.util.Collections;
30+
import java.util.stream.Collectors;
3031

31-
import com.google.common.io.CharStreams;
3232
import org.junit.Assert;
3333
import org.junit.Test;
3434

@@ -51,7 +51,7 @@ public void testChemFormatMatcherSet() {
5151

5252
protected boolean matches(String header) throws IOException {
5353
BufferedReader reader = new BufferedReader(new StringReader(header));
54-
return matcher.matches(CharStreams.readLines(reader)).matched();
54+
return matcher.matches(reader.lines().collect(Collectors.toList())).matched();
5555
}
5656

5757
@Test

0 commit comments

Comments
 (0)