I have java client application and I need to run a PHP script on server. That PHP scrips will create some word and excel files and than I want to download that created files on client's machine. Can I use somehow URL, but without opening a browser? And then download created files from server?
1 Answer
public class URLConnectionReader {
public static void main(String[] argv) {
try {
URL phpUrl = new URL("http://server/myphp.php");
URLConnection urlCon = phpUrl.openConnection();
BufferedReader br = new BufferedReader(
new InputStreamReader(
urlCon.getInputStream()));
String line;
while ((line = br.readLine()) != null)
System.out.println(line);
br.close();
} catch(Exception e) {
// handle errors here...
}
}
}
you will need to modify the php applicatin to receive some details about the results. Either the file location or maybe the file in MIME.
But you will need to add more information so we can help you out.
1 Comment
MrSimpleMind
you could use the apache http client with lots of good features for calling urls and mgmnt [link]hc.apache.org