Created
July 19, 2013 01:00
-
-
Save yeoupooh/6034328 to your computer and use it in GitHub Desktop.
Get QR code from Google chart.
This file contains 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
import java.io.BufferedInputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.net.URL; | |
import java.net.URLEncoder; | |
public class QRImage { | |
public static InputStream getInputStream(String host, int port) | |
throws IOException { | |
String serverUrl = URLEncoder.encode( | |
String.format("http://%s:%s", host, port), "UTF-8"); | |
URL url = new URL( | |
String.format( | |
"http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl=%s&chld=H|0", | |
serverUrl)); | |
InputStream in = new BufferedInputStream(url.openStream()); | |
return in; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment