views:

23

answers:

0

This code

private final String SERVICE_URL ="http://tables.googlelabs.com/api/query";
private final Pattern CSV_VALUE_PATTERN =
    Pattern.compile("([^,\\r\\n\"]*|\"(([^\"]*\"\")*[^\"]*)\")(,|\\r?\\n)");
private GoogleService service;
service = new GoogleService("fusiontables", "fusiontables.ApiExample");
service.setUserCredentials("[email protected]", "myPass", ClientLoginAccountType.GOOGLE);
runSelect("myQuery");
URL url = new URL(SERVICE_URL + "?sql=" + URLEncoder.encode(selectQuery, "UTF-8"));
GDataRequest request = service.getRequestFactory().getRequest(RequestType.QUERY, url, ContentType.TEXT_PLAIN);
request.execute();
Scanner scanner = new Scanner(request.getResponseStream());
while (scanner.hasNextLine()) {
                scanner.findWithinHorizon(CSV_VALUE_PATTERN, 0);
                MatchResult match = scanner.match();
                String quotedString = match.group(2);
                String decoded = quotedString == null ? match.group(1)
                        : quotedString.replaceAll("\"\"", "\"");
                System.out.print("|" + decoded);
                if (!match.group(4).equals(",")) {
                    System.out.println("|");
                }
            }

which i took from here is running normally in a netbeans Desktop application and the GDataRequest returns this

Lastname,Name,E-mail,Description,Coordinates
Αργυρόπουλος,Σταύρος,[email protected],ασδσδφγσδφδ,"<Point><coordinates>22.9401679,40.6362816,0</coordinates></Point>"
Καραγιανίδης,Κώστας,[email protected],σδφδσφσδφσδ,"<Point><coordinates>22.9501679,40.6462816,0</coordinates></Point> "
Κάργας,Στέφανος,[email protected],αβφγη,"<Point><coordinates>22.9307949,40.6577539,0</coordinates></Point> "

but if i put it in a bean in a Web application the GDataRequest returns gibberish like these

Lastname,Name,E-mail,Description,Coordinates
Ξ‘Ο?Ξ³Ο…Ο?Ο?πουλος,ΣταΟ?Ο?ΞΏΟ‚,[email protected],Ξ Ο?Ο?βλημα φωτισμοΟ? στο ΞΊΞ­Ξ½Ο„Ο?ΞΏ,"<Point><coordinates>22.9401679,40.6362816,0</coordinates></Point>"
 Ξ?Ξ±Ο?αγιανίδης,Ξ?Ο?στας,[email protected],Ξ Ο?Ο?βλημα ΞΏΞΌΞ²Ο?ίων,"<Point><coordinates>22.9501679,40.6462816,0</coordinates></Point> "
Ξ?Ξ¬Ο?Ξ³Ξ±Ο‚,Στέφανος,[email protected],Ξ?ιντζιλίκια,"<Point><coordinates>22.9307949,40.6577539,0</coordinates></Point> "

Any ideas? Thank you...