I
iksrazal
Hi all,
My problem: I want to burn a 1.2 gig file to CD, which obviously only
fits 700megs. So normally I would just use *nix split. However, I only
have at most 700 megs free hd space - split doubles the hd space
required. However, between swap and ram memory I have about 1 gig - and
I probably would have 700megs swap/memory free in runlevel 3. So I'm
thinking, why not just read the file via:
File file = new File("filename");
// Create a read-only memory-mapped file
FileChannel roChannel = new RandomAccessFile(file, "r").getChannel();
ByteBuffer roBuf = roChannel.map(FileChannel.MapMode.READ_ONLY, 0,
(int)roChannel.size());
And redirects its contents to stdout?
But then I got a few challenges. Please allow me to ask, as I could do
damage testing this:
1) Would changing the first iteration to this work?
ByteBuffer roBuf = roChannel.map(FileChannel.MapMode.READ_ONLY, 0,
650000000);
2) Second iteration:
ByteBuffer roBuf = roChannel.map(FileChannel.MapMode.READ_ONLY,
650000000, (roChannel.size() - 650000000));
3) Then the one I'm not sure about. How would I get the ByteBuffer to
stdout and call another program? I do the follwoing to output a big
file to a mysql shell:
Runtime rt = Runtime.getRuntime();
Process fRuntimeProcess = rt.exec(cmd);
FileInputStream fis = new FileInputStream(_scriptpath);
FileChannel fChan = fis.getChannel();
fChan.transferTo(0, fChan.size(),
Channels.newChannel(fRuntimeProcess.getOutputStream()));
Yet it requires FileChannel, not ByteBuffer. Hmm.
Its kind of screwy, I know, but it'd be kool if it worked!
Any ideas?
iksrazal
My problem: I want to burn a 1.2 gig file to CD, which obviously only
fits 700megs. So normally I would just use *nix split. However, I only
have at most 700 megs free hd space - split doubles the hd space
required. However, between swap and ram memory I have about 1 gig - and
I probably would have 700megs swap/memory free in runlevel 3. So I'm
thinking, why not just read the file via:
File file = new File("filename");
// Create a read-only memory-mapped file
FileChannel roChannel = new RandomAccessFile(file, "r").getChannel();
ByteBuffer roBuf = roChannel.map(FileChannel.MapMode.READ_ONLY, 0,
(int)roChannel.size());
And redirects its contents to stdout?
But then I got a few challenges. Please allow me to ask, as I could do
damage testing this:
1) Would changing the first iteration to this work?
ByteBuffer roBuf = roChannel.map(FileChannel.MapMode.READ_ONLY, 0,
650000000);
2) Second iteration:
ByteBuffer roBuf = roChannel.map(FileChannel.MapMode.READ_ONLY,
650000000, (roChannel.size() - 650000000));
3) Then the one I'm not sure about. How would I get the ByteBuffer to
stdout and call another program? I do the follwoing to output a big
file to a mysql shell:
Runtime rt = Runtime.getRuntime();
Process fRuntimeProcess = rt.exec(cmd);
FileInputStream fis = new FileInputStream(_scriptpath);
FileChannel fChan = fis.getChannel();
fChan.transferTo(0, fChan.size(),
Channels.newChannel(fRuntimeProcess.getOutputStream()));
Yet it requires FileChannel, not ByteBuffer. Hmm.
Its kind of screwy, I know, but it'd be kool if it worked!
Any ideas?
iksrazal