Respect my work! or BTC: 1MTFbBSKrocPK7G6GKfG8RoTw5N57WnnNa ![]() If you have paid donate send me e-mail with Your data or transaction number to receive an access code to articles with limited access. |
PmWiki /
Report generation in java languageDownload file getREPO.class Below I present a simple program showing how java program can generate a report using the system ProReports:
import java.net.*;
import java.io.*;
class getREPO {
public static void main(String[] args) {
String url="";
String file="";
if (args.length != 2)
{
System.out.println("Usage:");
System.out.println("java getREPO <file> <ProRepoURL> ");
return;
}
else
{
file=args[0] ;
url=args[1] ;
}
try {
URL proreports = new URL(url);
URLConnection proConn = proreports.openConnection();
//proConn.setReadTimeOut(30000);
//proConn.setConnectTimeout(30000);
//System.out.println(proConn.getReadTimeOut());
DataInputStream dis = new DataInputStream(proConn.getInputStream());
ByteArrayOutputStream bais = new ByteArrayOutputStream();
byte[] byteChunk = new byte[4096];
int n;
while ( (n = dis.read(byteChunk)) > 0 ) {
bais.write(byteChunk, 0, n);
}
OutputStream os = new FileOutputStream (file);
bais.writeTo(os);
dis.close();
} catch (MalformedURLException me) {
System.out.println("MalformedURLException: " + me);
} catch (IOException ioe) {
System.out.println("IOException: " + ioe);
}
}
}
This page may have a more recent version on pmwiki.org: PmWiki:GJAVA, and a talk page: PmWiki:GJAVA-Talk. |