CopyPastor

Detecting plagiarism made easy.

Score: 0.7514811158180237; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2019-07-04
by ORBIT

Original Post

Original - Posted on 2014-07-17
by Simon Kuang



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Try these using `stdin.hasNext()`

import java.io.BufferedInputStream; import java.util.Scanner; public class ReadMultiline { public static void main(String args[]) { Scanner stdinput = new Scanner(new BufferedInputStream(System.in)); while (stdinput.hasNext()) { System.out.println(Math.abs(stdinput.nextLong() - stdinput.nextLong())); String s=scanner.next(); } } }
I'd use some Java 8 tricks.
public static String streamToString(final InputStream inputStream) throws Exception { // buffering optional try ( final BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)) ) { // parallel optional return br.lines().parallel().collect(Collectors.joining("\n")); } catch (final IOException e) { throw new RuntimeException(e); // whatever. } }
Essentially the same as some other answers except more succinct.

        
Present in both answers; Present only in the new answer; Present only in the old answer;