diff options
-rwxr-xr-x[-rw-r--r--] | blatranslate.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/blatranslate.java b/blatranslate.java index af1f402..75f8f51 100644..100755 --- a/blatranslate.java +++ b/blatranslate.java @@ -26,15 +26,19 @@ import java.io.BufferedReader; import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
public class blatranslate {
- public static void main(String[] args) throws IOException
+ public static void main(String[] args) throws IOException, UnsupportedEncodingException
{
String query = "";
String sourceLang = "?";
String targetLang = "";
String sourceString = "";
+ PrintStream out = new PrintStream(System.out, true, "UTF-8");
+
/* Build query from query or arguments, depending on whether
arguments were given. */
if (args.length == 0) {
@@ -116,18 +120,18 @@ public class blatranslate { if(results.size() > 0){
for(int i=0; i< results.size(); i++){
if (i != 0) {
- System.out.print(" | ");
+ out.print(" | ");
}
int count = i + 1;
if(langs.size() > i-1 && langs.size() > 0) {
- System.out.print("Translation ("+langs.get(i)+" to "+targetLang+"): " + results.get(i));
+ out.print("Translation ("+langs.get(i)+" to "+targetLang+"): " + results.get(i));
} else {
- System.out.print("Translation ("+sourceLang+" to "+targetLang+"): " + results.get(i));
+ out.print("Translation ("+sourceLang+" to "+targetLang+"): " + results.get(i));
}
}
} else {
- System.out.print("Error: no results.\n");
+ out.println("Error: no results.");
System.exit(1);
}
System.out.print("\n");
|