• Post Reply Bookmark Topic Watch Topic
  • New Topic

Open a File without saving  RSS feed

 
Paras Ahuja
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
I have created an excel file using Apache POI. Now, i have three buttone in my GUI: Open, Save and Cancel (same as we get if we try to download something).
Now i have successfully implemented the save feature i.e. if anyone clicks on Save, the file is saved in C:/. But for Open, i want to just open the excel file without saving it.
Now, to just open the file, i first save it, use

to open it and then i delete the file using .
But it'snot deleted (maybe because it is open at the same time).
Hope you all undertsand what i'm trying to do. Please suggest any solution?
Thanks in advance...
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what i understand , is you are trying to save the file temporary and viewing it using "open " button and after close you are deleting the file but file is not deleted, this is because the file is still open in the process , if not then surely it will get deleted , i have tried and mine get deleted....hope this helps

one more thing if you are using FileInputStream or other such streams to read data from your excel file then your excel file won't get deleted unless you close your open streams or in most case your top level stream. if any doubt feel free to ask
 
Paras Ahuja
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Basically, I want to open the excel file when i click 'Open' but i don't want it to be saved on my system i.e. user can read it once he clicks Open. But when he closes the excel file, he has to again run the whole GUI to open the file, because it is NOT SAVED on system.
2.I'm not using any stream to read data from the any file. I create a new excel file in my program which can be saved,opened etc...
3. I'm just assuming here that when you deleted your file you did not open it first. If you did open it first to read it, let me know how did you delete the file?
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paras Ahuja wrote:1. Basically, I want to open the excel file when i click 'Open' but i don't want it to be saved on my system i.e. user can read it once he clicks Open. But when he closes the excel file, he has to again run the whole GUI to open the file, because it is NOT SAVED on system.

What you are using to show file MS-Excel ?
if yes than how can MS-Excel will open a file which is not present in the file system ?
Paras Ahuja wrote:
2.I'm not using any stream to read data from the any file. I create a new excel file in my program which can be saved,opened etc...

Are you making a excel file and showing in some editor like JTextEditor or JTextArea ?
Paras Ahuja wrote:
3. I'm just assuming here that when you deleted your file you did not open it first. If you did open it first to read it, let me know how did you delete the file?


Here if you specify any excel file then ms-excel will come in front and display your file and revise what i said you if the file is open in a process you cannot delete it , so now it wont be deleted, you need to make sure that the file is close and no application or process is using it then and only then the file will get deleted, hope now its clear if not ask me
 
Paras Ahuja
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, here's what i am trying to say:
Whenever we download something from internet, it asks:Do you want to open or save the file?
If i select 'Save', the file is saved on my PC. If i select 'Open', the file is displayed. But once i close the file and if i want to see it again, its not there on my PC. I have to again open the web page to open/save the file.
I have got the 'Save' feature successfully in Java. How do i implement the 'Open' button feature?
 
Ivan Jozsef Balazs
Rancher
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paras Ahuja wrote:How do i implement the 'Open' button feature?


By first writing it to some temporary storage?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!