aspose file tools*
The moose likes Java in General and the fly likes Problem using PrintStream class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem using PrintStream class" Watch "Problem using PrintStream class" New topic
Author

Problem using PrintStream class

Shital Kapadia
Ranch Hand

Joined: Jul 19, 2002
Posts: 34
Hello all:
I am pasting below a piece of code that is not behaving the way I would like it to. It only prints the results of the whois query for alexon-trend.com, it does not output the whois query results for seradyn.com. It is for this reason that I am checking in my code if the connection is open or not. I have even tried this code by inserting a out.flush() statement before issuing the next query for the next domain, that is, 'seradyn.com'.
Can anybody explain as to why is it that only the first query is being sent to the whois server by the PrintStream class, why does it not send the next query.
Pls guide me if I am doing anything wrong or missing some cleanup that is essential to be done before issuing the next query.
// Establish connection to whois server & port
Socket connection = new Socket(server, port);
PrintStream out = new PrintStream(connection.getOutputStream());
BufferedReader in = new BufferedReader(
new InputStreamReader(connection.getInputStream()));
String line = "";
domainName = "alexon-trend.com";
logger.debug("The query is: " + "whois " + domainName);
// Send the whois query to the whois server
out.println("whois" + " " + domainName);
//Read/output the query's result to a file 'whoislookup.txt'
dnsRecordWriter.writeDomainName(domainName);
while ((line = in.readLine()) != null)
{
logger.debug(line);
dnsRecordWriter.writeDnsData(line);
}
logger.debug("Is the socket closed: " + connection.isClosed());

domainName = "seradyn.com";
logger.debug("The query is: " + "whois " + domainName);
// Send the whois query to the whois server
out.println("whois" + " " + domainName);
// Read/output the query's result to a file 'whoislookup.txt'
dnsRecordWriter.writeDomainName(domainName);
while ((line = in.readLine()) != null)
{
logger.debug(line);
dnsRecordWriter.writeDnsData(line);
}

Thankls a lot,
Shital Kapadia
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem using PrintStream class