Skip to content

Instantly share code, notes, and snippets.

@sarnobat
Created April 24, 2020 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sarnobat/d8749ae9faddf97ab9537b4a84fa6f97 to your computer and use it in GitHub Desktop.
Save sarnobat/d8749ae9faddf97ab9537b4a84fa6f97 to your computer and use it in GitHub Desktop.
import java.io.*;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
public class Graphml2FileSystemStdin {
public static void main(String[] args) {
Multimap<String, String> parentToChildren = HashMultimap.create();
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(System.in));
String line;
while ((line = br.readLine()) != null) {
// log message
System.err.println("[DEBUG] current line is: " + line);
String[] elements = line.split("::");
String parent = elements[0];
String child = elements[1];
parentToChildren.put(parent, child);
// program output
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment