So basically I'm writing a program which outputs a website. The website should be written directly onto the server.
I am using this code to write to the server:
URL url = new URL("ftp://usr:pw@ftp.site.com/test/login.php;type=i");
URLConnection urlc = url.openConnection();
OutputStream os = urlc.getOutputStream(); // To upload
OutputStream buffer = new BufferedOutputStream(os);
PrintStream output = new PrintStream(buffer);
output.print(sb);
But sometimes my program runs and never terminates, so I'm guessing the connection is not being successful. '
Could I create a timeout in the case that this occurs? ie like 30 seconds, the connection would be automatically terminated so that the program could terminate.
Thanks in advance!