mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
IDEA-162875 Stream API migration: support conversion to BufferedReader.lines()
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
List<String> test(BufferedReader br) throws IOException {
|
||||
List<String> result;
|
||||
result = br.lines().map(String::trim).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
List<String> test(List<BufferedReader> readers) throws IOException {
|
||||
for(BufferedReader br : readers) {
|
||||
List<String> result;
|
||||
result = br.lines().map(String::trim).collect(Collectors.toList());
|
||||
if(result.size() > 10) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with sum()" "true"
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Main {
|
||||
void test(BufferedReader br) throws IOException {
|
||||
long count = br.lines().map(String::trim).mapToLong(String::length).sum();
|
||||
System.out.println(count);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
List<String> test(BufferedReader br) throws IOException {
|
||||
List<String> result = new ArrayList<>();
|
||||
String line = "";
|
||||
wh<caret>ile(null != (line = br.readLine())) {
|
||||
result.add(line.trim());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// "Replace with collect" "false"
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
List<String> test(List<BufferedReader> readers) throws IOException {
|
||||
List<String> result = new ArrayList<>();
|
||||
for(BufferedReader br : readers) {
|
||||
String line = "";
|
||||
wh<caret>ile (null != (line = br.readLine())) {
|
||||
result.add(line.trim());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
List<String> test(List<BufferedReader> readers) throws IOException {
|
||||
for(BufferedReader br : readers) {
|
||||
List<String> result = new ArrayList<>();
|
||||
String line = "";
|
||||
wh<caret>ile (null != (line = br.readLine())) {
|
||||
result.add(line.trim());
|
||||
}
|
||||
if(result.size() > 10) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with sum()" "false"
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Main {
|
||||
void test(BufferedReader br) throws IOException {
|
||||
String line = "";
|
||||
long count = 0;
|
||||
wh<caret>ile((line = br.readLine()) != null) {
|
||||
line = line.trim();
|
||||
count+=line.length();
|
||||
}
|
||||
System.out.println(count);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with sum()" "true"
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Main {
|
||||
void test(BufferedReader br) throws IOException {
|
||||
String line = "";
|
||||
long count = 0;
|
||||
wh<caret>ile((line = br.readLine()) != null) {
|
||||
String trimmed = line.trim();
|
||||
count+=trimmed.length();
|
||||
}
|
||||
System.out.println(count);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with sum()" "false"
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Main {
|
||||
void test(BufferedReader br) throws IOException {
|
||||
String line = "";
|
||||
long count = 0;
|
||||
wh<caret>ile((line = br.readLine()) != null) {
|
||||
String trimmed = line.trim();
|
||||
count+=trimmed.length();
|
||||
}
|
||||
System.out.println(count+":"+line);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user