Download Stuff From Reddit Using Java
Previously I’ve looked at how to download stuff from Reddit. So I thought I’ll re-apply the same code, but using Java. Here is the same code to do just that.
import java.io.*; import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; import java.nio.charset.Charset; import java.nio.file.*; import java.util.Arrays; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; public class getWallpaper { private static final String OPEN_SUBREDDIT = "http://www.reddit.com/r/%s/.json"; public static String readAll(Reader rd) throws IOException { StringBuilder sb = new StringBuilder(); int cp; while ((cp = rd.
[Read More]