filechannel Questions

2

Background We want to let the user choose a video from any app, and then trim a video to be of max of 5 seconds. The problem For getting a Uri to be selected, we got it working fine (solution av...

3

Solved

In the following example, I have one file being used by two threads (in the real example I could have any number of threads) import java.io.File; import java.io.IOException; import java.io.RandomA...
Saltpeter asked 10/9, 2018 at 15:28

0

This question has been confusing me for days: Assume that I have two processes (p_write and p_read) which run on the same machine. Process p_write is for writing/updating the mmap file. Process ...

7

I'm playing around with the NIO library. I'm attempting to listen for a connection on port 8888 and once a connection is accepted, dump everything from that channel to somefile. I know how to do i...
Marty asked 4/10, 2011 at 17:9

2

I am creating a RandomAccessFile object to write to a file (on SSD) by multiple threads. Each thread tries to write a direct byte buffer at a specific position within the file and I ensure that the...
Ellerd asked 30/7, 2017 at 4:7

1

Solved

I have a class works like FilterOutputStream. public class WritableFilterChannel implements WritableChannel { public WritableFilterChannel(final WritableByteChannel channel) { super(); this.ch...
Autotomize asked 18/1, 2016 at 16:21

1

(This is related to (or rather the "opposite" of) Would FileChannel.read read less bytes than specified if there's enough data? ) TL;DR : Will this always write the whole buffer... ByteBuffe...
Teeny asked 29/4, 2015 at 13:47

1

Solved

My application uses Java class RandomAccessFile to read/write bytes to a file on SD card randomly by means of realization of SeekableByteChannel interface. Now I need rewrite it for Android 5.0 wit...

1

Solved

FileChannel.transferFrom(source, 0, source.size()) gives the following OutOfMemory exception, when trying to copy a file of size around 2GB. I understand the memory issue due to larger files. Can w...
Adcock asked 22/1, 2015 at 12:8

1

I'm trying to get the size of a file contained in assets. I'm using a FileChannel because I need a FileChannel later. The file myfile.txt contains 7 bytes. Here is my code: AssetManager amgr; Ass...
Overfill asked 25/2, 2014 at 16:42

2

Solved

I am writing values to a file. The values are written correct. In another application I can read the file without any exceptions. But in my new application, I get a Bufferunderflowexception when tr...

2

Solved

I don't know where to seek clarifications and confirmations on Java API documentation and Java code, so I'm doing it here. In the API documentation for FileChannel, I'm finding off-by-one errors w...
Grammer asked 1/12, 2013 at 5:48

4

Solved

I am really in trouble: I want to read HUGE files over several GB using FileChannels and MappedByteBuffers - all the documentation I found implies it's rather simple to map a file using the FileCha...
Mccarter asked 21/9, 2012 at 13:56

7

I'm working on something that uses ByteBuffers built from memory-mapped files (via FileChannel.map()) as well as in-memory direct ByteBuffers. I am trying to understand the concurrency and memory m...
Navarrette asked 9/8, 2011 at 20:27

2

Because you cannot redirect GC logs I am left with the option to redirect it to a file with -Xloggc and then get the contents of this file inside my selector through a file channel of some kind. Ba...
Abshier asked 24/3, 2012 at 22:19

4

Consider application, which create 5-6 threads, each thread in cycle allocate MappedByteBuffer for 5mb page size. MappedByteBuffer b = ch.map(FileChannel.MapMode.READ_ONLY, r, 1024*1024*5); Soon...
Follmer asked 18/12, 2011 at 16:41

2

Solved

I came across an issue with one of our utility classes today. It is a helper for files and contains some static file copy routines. Below are the relevant methods extracted along with a test method...
Brass asked 9/11, 2011 at 14:2

2

I need to read/unpack a .gz file given a FileChannel. I've played around with extracting GZIP archives using GZIPInputStream, but this won't take a FileChannel. I don't have access to the origina...
Deciare asked 26/7, 2010 at 14:49

2

Solved

Can I write any InputStream into a FileChannel? I'm using java.nio.channels.FileChannel to open a file and lock it, then writing a InputStream to the output file. The InputStream may be opened by ...
Hayne asked 8/7, 2011 at 2:53

1

Solved

I would like to make it clear and draw some parallels between FileOutputStream and FileChannel right now. So first of all, it seems like the most efficient way to write file with standart Java io ...
Tardif asked 20/1, 2011 at 1:13

2

Solved

I'm in the process of making some changes to a library that I'm using. In order to reduce memory usage the library is writing its temporary data to disk instead of keeping it in memory. However, fo...
Barela asked 16/12, 2009 at 14:41

6

Solved

I have the following code: String inputFile = "somefile.txt"; FileInputStream in = new FileInputStream(inputFile); FileChannel ch = in.getChannel(); ByteBuffer buf = ByteBuffer.allocateDirect(...
Toulouselautrec asked 18/9, 2008 at 15:9
1

© 2022 - 2024 — McMap. All rights reserved.