Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package qa10116588765;
- import java.util.*;
- public class Main {
- private StringBuilder sb;
- public void parse(Scanner in) {
- sb = new StringBuilder();
- sb.append("{");
- while (in.hasNextLine()) {
- Scanner line = new Scanner(in.nextLine());
- String head = line.next();
- if (head.isEmpty()) continue;
- sb.append("" + head + ": \"");
- while (line.hasNext()) {
- sb.append(line.next());
- if (line.hasNext()) sb.append(" ");
- }
- line.close();
- sb.append("\"");
- if (in.hasNextLine()) sb.append(", ");
- }
- in.close();
- sb.append("}");
- }
- @Override
- public String toString() {
- return sb.toString();
- }
- public static void main(String[] args) {
- Main main = new Main();
- Scanner in = new Scanner("aaa\tbbb\nccc\tddd\n");
- // Scanner in = new Scanner(System.in);
- main.parse(in);
- System.out.println(main);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement