I have a ByteBuffer containing bytes that were derived by String.getBytes(charsetName), where "containing" means that the string comprises the entire sequence of bytes between the ByteBuffer's position() and limit().
What's the best way for me to get the string back? (assuming I know the encoding charset) Is there anything better than ...
Is there a way (without buffering the whole Inputstream) to take the HttpServletRequest from a Java Servlet and write it out to a file using all NIO? Is it even worth trying? Will it be any faster reading from a normal java.io stream and writing to a java.nio Channel or do they both really need to be pure NIO to see a benefit? Thanks....
Hello, everyone!
Please help me understand the following:
I create a CharBuffer using
CharBuffer.wrapped(new char[12], 2, 10) (array, offset, length)
so I would expect that the array is accessed with an offset of 2 and total (rest) length of 10. But arrayOffset() returns 0.
What I want to understand (and can't figure out from JavaDoc)...
I'm working on Clojure app where a client needs to send some commands to a server. These will happen in quite large volumes, so I'd like it to be reasonably efficient, both in terms of processing and over-the-wire serialised size.
What would be the best way of doing this in Clojure?
Currently I'm thinking of:
Creating a simple standa...
Hi,
I am trying to write a TCP server that reads data sent by the client. I want to keep the client connection open after the read to be able to read any subsequent data sent.
The code I am executing is below :
while(true) {
try {
int keysSelected = selector.select();
System.out.println("keysSelect...
It seems to be pretty fast already and i was just wondering if anyone knows if its using NIO. I tried searching the whole source code for NIO (well, its kind of way to search :) lol); but did not hit anything. Also, If its not using NIO; do you think its worthwhile to modify log4j to use NIO also to make it more faster? Any pointers advi...
Hello All,
Is there a Java RTP/RTCP library based on Java NIO or some Java NIO framework (Netty, MINA, ...)?
...
We building a Netty/NIO based service, and I'm considering the deployment of this service to our production environment. Our standard way of deploying services is as WARs, to be deployed inside Tomcats.
When I suggested the same approach here, I got shouts and complaints that "it shouldn't be done", because both Netty and Tomcat are ser...
I am using JDK 7's WatchService to monitor directories.
The ENTRY_DELETE event tells me an entry has been deleted. I can get the name of that entry doing something similar to:
WatchEvent<Path> ev = cast(event);
Path name = ev.context();
Path child = dir.resolve(name);
I want to know if the deleted entry was a file or folder. Naturall...
Just started playing around with netty in implementing my own server. Took me a while to get the hang of it but now I was able to accept clients by writing my own MessageHandler and inside messageReceived I was able to read from the buffer and did some business logic related to the data received.
However the question now is, how do I w...
I have the following simple code in my netty project, it expects to read an integer from the upstream. No encoder is in the pipeline.
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
ChannelBuffer m = (ChannelBuffer) e.getMessage();
m.readInt()
}
When the data comes in fro...
How can one implement read(ByteBuffer dst, long timeout, TimeUnit unit, A attachment, CompletionHandler<Integer,? super A> handler) on top of an existing AsynchronousByteChannel?
That is, how can one implement read-with-timeout functionality on top of AsynchronousByteChannel that does not support timeouts?
Unlike AsynchronousSocketChan...
What does this do in netty?
bootstrap.setOption("child.connectTimeoutMillis", x);
...
Hi,
I'm implementing a Non-Blocking HTTP server in Java and decided to use pure Java NIO. I'm combining a NIO Selector with a small thread pool to perform the operations indicated by the selector.
Leaving the system choose the default selector (tested in Linux 2.6 epoll and Mac OS Snow Leo KQueue) and using Selector.select(TIMEOUT); I ...
I am building a non blocking server using javas NIO package, and have a couple questions about validating received data.
I have noticed that when i call read on a socket channel, it will attempt to fill the byte buffer that it is reading to (as per the documentation). When i send 10 bytes to the server from the client, the server will r...
I have some data files looking something like this:
text
header
"lots of binary data hear"
/header
more text
header
"more binary data"
/header
....
Most of the files are around 1-5MB in size. It's very unlikely that I will have to deal with any files larger than approximately 30MB.
I'm fairly new to Java NIO and the API looks a bit l...
Here's my problem: one big gzipped file; millions of messages.
Each message consists of:
***************** *************** ******************
* 2-byte LENGTH * * 1-byte TYPE * * N-byte PAYLOAD * , where N = (LENGTH-1).
***************** *************** ******************
Depending on the TYPE, I need to read a few bytes from an off...
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 original FileInputStream that the FileChannel was taken from.
If someone could tell me a good way (or at least any way) of reading GZIP from a FileC...
I'm currently playing around with java.nio, which I haven't been using for a long time. I use Google Protocol Buffers for serialization and for communication with other parts of my system. Now I can't figure out if/how it is possible to get use protobuffers with java.nio classes.
I can't imagine that Google is using only "one thread per...
Hey guys,
My problem is that I have an app which is writing a lot of relatively (100-500kb) small CSV files (tens and hundreds of thousands ). Content of those files then get loaded in database via sql loader call (its oracle db) and this is what I have to live with.
So, I need to remove those small files time to time to prevent them...