Getting the raw content from pastebin [Java]

1.9k views Asked by At

When I try to retrieve the data from a pastebin and convert it to a string. It returns nothing. Just an empty line.

Code:

try {
    URL url = new URL("http://pastebin.com/raw.php?i="+pasteKey);
    String text = new BufferedReader(new InputStreamReader(url.openStream(), 
             StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n"));
    System.out.println(text);
} catch (IOException e) {
    e.printStackTrace();
}

I have tried using GET but got the same result

1

There are 1 answers

1
DiamondPG On

I had this problem when I was developing with Construct 2. I had to use an external website to bypass some security protocol. I don't remember what it was, but it worked. Here is the website. https://api.allorigins.win/raw?url=. Paste your raw url after "url="

I realize I am very late. but if you are still stuck on it, I hope this helps.