salve!
ho questo metodo che richiama un file php remoto passando un valore in get:
codice:
private final String remoteFile = "http://www.miosito.com/";
private Gson gson = new Gson();
private JsonParser parser = new JsonParser();
public String getAllBooksOfAuthor(int author) throws IOException {
String booksAuthorFile = remoteFile + "file.php?author=" + author;
StringBuilder sb = new StringBuilder();
try (BufferedReader bf = new BufferedReader(new InputStreamReader(new URL(booksAuthorFile).openStream()))) {
JsonArray jarray = parser.parse(new JsonReader(bf)).getAsJsonArray();
for (JsonElement e : jarray) {
Book book = gson.fromJson(e, Book.class);
sb.append(book.title).append("\n");
}
}
return sb.toString();
}
solo che vorrei passare il dato in posto anzichè in get.
è possibile??