• Post Reply Bookmark Topic Watch Topic
  • New Topic

Runtime hangs when writing to a file  RSS feed

 
Rashid Darvesh
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i have a java program which generates a tab delimited file. I am calling it thru a web application using Runtime class. The problem is that the program hangs after a certain time. If i run the program thru the command prompt it runs fine, but when it is called thru the WEbapplication it hangs. Any idea what is the problem
Thanks
Rashid
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you running it on the server or on the client, the first thing I will check is the security...
 
Paul Clapham
Sheriff
Posts: 22701
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or it could be something in here:

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rashid Darvesh:
Hi
i have a java program which generates a tab delimited file.


Can you post your code?
 
Rashid Darvesh
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following is the code snippet which i used. i am using xml database. iget all the asset id at once and iterate over them one by one and write it to a file. Please let me know if you need more information

con = this.factory.newConnection();
XDBCStatement xstmt = con.createStatement();
String assetIdXquery = IMPORT_PREFIX + "\n" + "zap:get-published-ei-asset-ids()";
assetIdRs = xstmt.executeQuery(assetIdXquery);
while (assetIdRs.hasNext()) {
assetIdRs.next();
String assetId = assetIdRs.getString().asString();
assetL.add(assetId);
}
System.out.println("Asset Count: " + assetL.size());
Iterator it = assetL.iterator();
while(it.hasNext()){
cnt++;
String assetId = it.next().toString();
System.out.println("Counter " + cnt + " : " + assetId );
String assetXquery = IMPORT_PREFIX + "\n" + "zap:get-published-ei-report-test" + "(\"" + assetId + "\")";
assetRs = xstmt.executeQuery(assetXquery);
while (assetRs.hasNext()) {
assetRs.next();
String result = assetRs.getString().asString();
String line= composeString(result);
writeToFile(line,fos);
String lineForThumb = null;
lineForThumb = composeStringForThumb(result);
if (lineForThumb!=null){
writeToFile(lineForThumb,fosForThumb);
}
}
assetRs.close();
}

Let me know if you need more information
Thanks
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!