• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Open a file on the fly

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
It's feeding time! Give me the food you were going to give to this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic