OVERVIEW: I'm working on a scanning project where I scan documents and upload them to an IBM iSeries Server using a propriety mechanism IBM calls IFS (Integrated File System). The project is an applet. I'm using this to create my TIFF images: http://asprise.com/product/jtwain/javadoc/index.html
NEEDED: My problem is that the createTIFFFromImages method wants to write to a file on the file system; however, I want to write to memory so I can pass the bytes to my IFS class and upload the image to the remote server. Another words I'm trying to refrain from writing anything to the local file system. I wish to direct the image like this: scanner->memory->IFS without touching the local file system.
I don't see that method in the index of the API you linked to there. Is it possible that somebody else wrote it? In my opinion a properly-designed method that outputs to a File would have an overloaded version that outputs to an OutputStream; you would then use that method to write to an IFSFileOutputStream. Double-check your documentation to see if that is the case, and perhaps you can harass the writer of the method to provide the overload.
Or you could do what I do, which is to map the IFS to a Windows drive.
Joined: Jan 10, 2006
Paul I appreciate the reply. I'm avoiding a mapped drive scenario altogether. This software will be used by around 60 remote locations and mapping issues are just one of many that I do not wish to face.
In any case, Brandon, java.io.File is an abstraction for a path, nothing more, nothing less. It doesn't do any I/O itself, so no amount of subclassing is going to have the effect you want. What you need is a "creatTIFFFromImages()" that works with an OutputStream instead of a File -- can you find a method like that?
[EFH]: It doesn't do any I/O itself, so no amount of subclassing is going to have the effect you want.
Mmmmh, File is able to do some IO on its own, unfortunately. E.g. createNewFile(), delete(), mkdir(). Would've been nice if they'd cleanly separated the IO functionality from the abstraction for a path - but they didn't. It's quite a pain if you're on a project that does a lot of IO, and people keep writing "unit tests" that end up inadvertently depending on the underlying file system. Meaning the tests may not run in someone else's environent. We had a FileUtils abstraction that was useful in isolating most of the IO, but people were still passing File objects around, and weeding out these dependencies is difficult. Even something innocuous-looking like getCanonicalName() actually does depend on accessing the underlying filesystem to see what's there, which can yield inconsistent results. We probably should have introduced another abstraction - FilePath or some such - to allow more code to be able to refer to file paths without having the ability to do actual IO. Lessons for next time, I guess.
Anyway, back to Brandon: it's still unlikely that overriding methods in File will help you here. The problem is that this creatTIFFFromImages() is probably using a FileOutputStream, FileChannel, or RandomAccessFile, initialized from the File object. Not much you can do about that, unless you can find an alternate way to create images to an OutputStream or Channel of some sort, as Paul and EFH said. Good luck... [ January 10, 2006: Message edited by: Jim Yingst ]
I think im sharing a similar problem with Brandon. In my case, its PDF > images to memory > extract image properties without writing it as physical file. I'll be watching this discussion for further info i could get. Tanks guys for the suport
I just cant look, its killing me.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Override java.io.File to write to memory?