How to add a flow?

Good afternoon. Help add to my code the flow with a stop sleep.

Here is an example that I want to add

Here is my code
package test;

import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.An InputStreamReader is;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

import org.json.JSONObject;

public class MAin {
 public static void main(String[] args) {
 String urlVK = "https://api.vk.com/method/photos.search?&radius=10000&lat=48.24523&long=58.2523&access_token=7075966f7075966f7075966f577018909e770757075966f2dfd2579655817dfd28d3bfd&v=5.103";
 try { 
 URL URL = new URL(urlVK);
 // read from the URL
 Scanner scan = new Scanner(url.openStream());
 String str = new String();
 while (scan.hasNext())
 str += scan.nextLine();
scan.close();

 // build a JSON object
 JSONObject obj = new JSONObject(str);
 pageName int = obj.getJSONObject("response").getInt("count");
System.out.print(pageName);
 try {
 for(int i=0;i < pageName; i=i+1000) {
 String urlVKoffset = "https://api.vk.com/method/photos.search?&radius=10000&lat=48.24523&long=58.2523&access_token=7075966f7075966f7075966f577018909e770757075966f2dfd2579655817dfd28d3bfd&v=5.103"
 + "&offset=" + i;
 ObjVK URL = new URL(urlVKoffset);
 HttpURLConnection connection = (HttpURLConnection) objVK.openConnection();
connection.setRequestMethod("GET");
 BufferedReader in = new BufferedReader(new an InputStreamReader(connection.getInputStream()));
 String inputLine;
 StringBuffer response = new StringBuffer();
 while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
/*
System.out.println(response.toString());
*/
 try (FileWriter file = new FileWriter("response-vk" + i + ".json")) {
file.write(response.toString());
 } 
}
 }catch(Exception e){}
}
 catch(Exception e){}
 } 
}
April 3rd 20 at 18:46
1 answer
April 3rd 20 at 18:48
And in what place you want to add flow? And in any case you want to do is sleep?

Find more questions by tags Java