- package com.company;
- import java.io.*;
- import java.net.URL;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) throws IOException {
- URL url = new URL("https://jsonplaceholder.typicode.com/posts");
- Scanner sc = new Scanner(url.openStream());
- StringBuffer sb = new StringBuffer();
- while(sc.hasNext()) {
- sb.append(sc.next());
- }
- String result = sb.toString();
- File file;
- String[] strs = result.split("(},)");
- for(int j = 1; j<strs.length + 1; j++){
- file = new File("id="+ j + ".json");
- FileWriter myWriter = new FileWriter("id="+ j + ".json");
- myWriter.write(strs[j-1] + "}");
- myWriter.close();
- file.createNewFile();
- }
- }
- }
[text] json
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: