Created
June 12, 2017 15:33
-
-
Save leonardocordeiro/ee593a5a1f35d53bd292a2c4eed95cf5 to your computer and use it in GitHub Desktop.
cliente sse com urlconnection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.lema.notasapp.infra.filter; | |
import java.io.BufferedReader; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
import java.net.URLConnection; | |
import java.util.Scanner; | |
/** | |
* Created by leonardocordeiro on 11/06/17. | |
*/ | |
public class Teste { | |
public static void main(String[] args) throws Exception { | |
HttpURLConnection url = (HttpURLConnection) new URL("...").openConnection(); | |
url.setRequestProperty("Content-type", "text/event-stream"); | |
url.setRequestProperty("Accept", "text/event-stream"); | |
url.setRequestMethod("GET"); | |
InputStream inputStream = url.getInputStream(); | |
Scanner s = new Scanner(inputStream); | |
while(s.hasNextLine()) { | |
System.out.println("args = " + s.nextLine()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment