You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Alvin Kutttikkat Antony <aa...@gw.ifkw.uni-muenchen.de> on 2002/02/13 14:05:28 UTC
Best way to write Export files
Hi there,
I have to write export files to an another server.The code I am using is not seams to be working fine .Some times it rewrites on an existing file.I am giving my code sample here
access = ACCESS_WRITE;
long time = System.currentTimeMillis();
long timeSpawned = time;
// this routine tries 30 seconds
// to open a file, if not successful
while(!isOpen && (((timeSpawned-time)/1000)<30))
{
timeSpawned = System.currentTimeMillis();
try
{
out = new BufferedWriter(new FileWriter(filename,true));
isOpen = true;
}
catch(IOException e)
{
}
}
}
if(isOpen)
{
String line = "";
for(int i=0; i<attributes.length; i++)
{
String att = person.getAttribute(attributes[i]);
if(att==null && attributes[i].equals(PersonKeys.DATATYPE))
att = "cha";
if(att==null)
att = "";
line += att + delimiter;
}
out.write(line);
out.newLine();
out.flush();
}
Is there is an another better way to do this?
appreciating your replay
Alvin
alvin kuttikkat antony
Internet und Virtuelle Hochshule
Directory
Universität München
Leopoldstr .3
80802 München
Germany
Office Tel + 49.89.21025979
Office Fax + 49.89.21025980