Skip to content

Instantly share code, notes, and snippets.

@kedarmhaswade
Created April 5, 2016 00:12
Show Gist options
  • Save kedarmhaswade/a12c8c20f86d998474bb14d0e0b533cb to your computer and use it in GitHub Desktop.
Save kedarmhaswade/a12c8c20f86d998474bb14d0e0b533cb to your computer and use it in GitHub Desktop.
Does Java Use the right IP version?
package tmp;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
/**
* Created by kmhaswade on 3/31/16.
*/
public class Tmp {
public static void main(String[] args) throws IOException {
URL u = new URL("http://localhost:8080");
URLConnection uc = u.openConnection();
uc.connect();
System.out.println(System.getProperty("java.net.preferIPv6Addresses"));
BufferedReader br = new BufferedReader(new InputStreamReader(uc.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment