Hi all,
I am facing problem as below in my
java program.
I want to write data from stream into text file & then process that created text file. The data in stream is very big & it creates text file with 600-700 lines. And then I want to process that text file.
I am doing it as below:-
_______________________________________________________________________________________________________
FileOutputStream fos = null;
try {
fos = new FileOutputStream("c:\\pal\\b.txt");
IOStreamConnector output = new IOStreamConnector(session.getInputStream(), fos);
session.getOutputStream().write("*****some big inputstream source here******");
fos.close();
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidStateException e) {
e.printStackTrace();
}
FileUtility.readxmluserfile("c:\\pal\\b.txt");
_______________________________________________________________________________________________________
Now here the problem occuring is, before the b.txt file gets written completely with stream data, the method "readxmluserfile" starts executing, which is not desirable.
The method "readxmluserfile" should start executing only after the content from stream gets completely dumped into text file.
I tried one quick solution by placing line "Thread.currentThread().sleep(5000);" before call to method "readxmluserfile" which pauses current
thread for 5 seconds then executes "readxmluserfile". However this is not proper way to do that. Can you please suggest me proper way to achieve above?
Many thanks in advance.
--Pras