Last active
May 3, 2018 09:22
-
-
Save devinrsmith/c2dddc652fbffe6404e9 to your computer and use it in GitHub Desktop.
UrlTest
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
javac -encoding UTF8 /pwd/UrlTest.java | |
java -cp /pwd UrlTest | |
rm /pwd/UrlTest.class |
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
javac -encoding UTF8 /pwd/UrlTest.java | |
java -cp /pwd -Dfile.encoding=UTF8 UrlTest | |
rm /pwd/UrlTest.class |
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
import java.io.IOException; | |
import java.net.HttpURLConnection; | |
import java.net.URI; | |
/** | |
* Created by dsmith on 4/8/15. | |
*/ | |
public class UrlTest { | |
public static void main(String[] args) throws IOException { | |
final HttpURLConnection urlConnection = (HttpURLConnection) | |
URI.create("http://prod3.agileticketing.net/images/user/mfsf_3683/Tokyo-Fianceé-1.jpg"). | |
toURL(). | |
openConnection(); | |
System.out.println(urlConnection.getResponseMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've run into this issue a couple times, where we'll pass around a pre-built jar and different environments act differently by default. As it stands now, the responsibility lies on me to always remember when using docker java to pass
-Dfile.encoding=UTF8
(and it's probably good practice anyways). But again... whenever a bug like this pops up it takes me a couple hours to figure out what's going on and that's never fun. Should the docker java image have UTF8 by default?