• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FBN conversion program - datafile won't create under UNIX

 
John Sinues
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one of the earlier assignments which requires the development of a conversion program.
Under Windows, the program works fine. When I type

a db.db file is created in the local directory.
Unfortunately, under UNIX (Red Hat, Mandrake, and SunOS), running the same command does not result in a file being created. The program completes correctly and no errors are reported. However, if I create the file first by typing

then run the above command, everything behaves normally. I've tried different shells (sh, csh, tcsh, bash) with no success. Directory permissions are 777.
Any ideas?
- John
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John
Can you tell us which class and methods you are using to create the file?
Does the program work if you extract the classes from the jar file and run them manually? (I can't see any reason why it would).
Try with a very simple program first that just creates a file ... see if that works. Even something as simple as:

I just checked that this worked on my RedHat system - directory permissions were 775. No problems.
Regards, Andrew
 
John Sinues
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,
Thanks for the quick response.
In response to some of your questions:
1. The example code that you provided works fine under Red Hat, SunOS, and Windows.
2. Methods/classes to create the file, here's a code excerpt:


After looking at the code, again, I'm beginning to think the .delete() method is the culprit under Unix. What do you think?
- John
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John
Sorry for the late response.
I would also suspect that the delete is causing your problems.
To be honest - I don't understand what this code is doing.
  • Your first try catch block should create the file unless it exists, in which case you give an option to delete it.

  • Wouldn't it be easier just to use the normal File.exists() method rather than trying to create the file to verify if it exists?
  • If it was created, or if the user chose to delete it, then it is deleted.
  • You then attempt to create it again.

  • When you delete the file, you are not clearing out your airlineDataFile variable, so the second attempt to create the file will not be called.
    So what you are doing may depend on how the OS handles the file pointer that you Data instance currently has. It could decide that the underlying file is gone, and therefore you cannot write to it, or it may decide to just recreate the file on the fly for you.
    That's my interpretation anyway.
    Regards, Andrew
    [ July 17, 2003: Message edited by: Andrew Monkhouse ]
     
    John Sinues
    Ranch Hand
    Posts: 52
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Andrew,
    I greatly appreciate your input.

    To be honest - I don't understand what this code is doing.
    Your first try catch block should create the file unless it exists, in which case you give an option to delete it.
    Wouldn't it be easier just to use the normal File.exists() method rather than trying to create the file to verify if it exists?

    After running the sample code that you provided, I kept wondering to myself, why didn't I use the File.exists() method The way I implemented the creation of the datafile, as you pointed out, was not clear. So I reworked the code using the File.exists() method and tested it this morning. Everything works now.
    It's been awhile since I actually worked on my conversion program (January 2001 according to the header). I can finally see the end to this project. Just a couple more weeks then I think I'll be ready to take the plunge and submit my project and take the exam. Thanks again for your input and the code review -- you just saved me a couple of points!
    - John
    [ July 18, 2003: Message edited by: John Sinues ]
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic