Results 1 to 4 of 4
  1. #1
    sara12345 is offline Member
    Join Date
    Dec 2009
    Posts
    59
    Rep Power
    0

    Default taking data from recent output file

    hello
    I have called whlole c code from java and then as result of calling c code from java the output file is saved. I need to call c code several times from java and then I need to use the data from the output file to do some calculations. but my problem is how to make sure that the data taken from the output file is taken from recent output file and how to make sure that the output file is saved before executing next command in java???
    thanks alot

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    832
    Rep Power
    6

    Default

    Please give the glimpse of code here.
    Ramya:cool:

  3. #3
    sara12345 is offline Member
    Join Date
    Dec 2009
    Posts
    59
    Rep Power
    0

    Default

    ok the code I have used to call c code from java is the following:
    Java Code:
    			String line;
    		 	Process p = Runtime.getRuntime().exec("getting_output.exe");
    		 	BufferedReader input =new BufferedReader(new InputStreamReader(p.getInputStream()));
    
    		 	while ((line = input.readLine()) != null) {
    		 		System.out.println(line);
    		 	}
    
    		 	input.close();
    I just have question if I want to execute c code from java several times and then read output file how can I make sure that I have read the most recent one
    thanks

  4. #4
    gcampton Guest

    Default

    If you have closed the source, ie input.close(); then it should be saved at whatever the last modification was, and now is ready to be opened again.

    That's my guess anyway, I know this works in C++ I had a same type of exercise.

Similar Threads

  1. Replies: 3
    Last Post: 11-11-2009, 09:00 PM
  2. Replies: 0
    Last Post: 02-28-2009, 11:16 AM
  3. Replies: 5
    Last Post: 02-05-2009, 10:28 AM
  4. Taking input from Properties File
    By bugger in forum New To Java
    Replies: 4
    Last Post: 05-07-2008, 09:30 AM
  5. Weird data output
    By Shaolin in forum New To Java
    Replies: 12
    Last Post: 12-11-2007, 04:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •