permaculture playing cards*
The moose likes Java in General and the fly likes Open a file on the fly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Open a file on the fly" Watch "Open a file on the fly" New topic
Author

Open a file on the fly

Marco Lombardo
Ranch Hand

Joined: Jul 05, 2005
Posts: 71
Is there way to open a file without save it in file system?
For example:
I have a byte[] object or java.io.File (or Stream) and i want to
open a file without save it.

Can i use Runtime.getRuntime().exec(....) to open a file
not in file system?


Team Leader<br />SCJP, SCBCD , SCDJWS, Oracle WebLogic, IBM WebSphere e IBM FileNet Certified<br /> <br /><a href="http://www.marcolombardo.it" target="_blank" rel="nofollow">http://www.marcolombardo.it</a>
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
What do you mean by "open a file without saving it?". A file cannot be opened unless it exists on disk.

Perhaps you are thinking of the way you can open a new document in, say, Microsoft Word, without saving it. That's something completely different. You could implement such a user interface in Java, but that has little to do with Java File objects.

You can create a Java File object for a file that does not exist. A Java File object is just an abstract pathname. However, creating a Java File object does not mean you have "opened" the file. To open the file, you need a RandomAccessFile, an InputStream, an OutputStream or an NIO channel (I'm a bit hazy on them). For any of those, the file must already exist or will be created as part of the opening process.
[ July 17, 2006: Message edited by: Peter Chase ]

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Please don't post the same question to multiple forums; I deleted the other copy you posted in IO and Streams because this one already has a discussion.

I also can't really understand what you're asking, but does java.io.ByteArrayInputStream help you?


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Open a file on the fly