I'm trying to do local IPC using Sockets and Object streams in Java however I'm seeing poor performance.
I am testing the ping time of sending an object via an ObjectOutputStream to receiving a reply via an ObjectInputStream over a Socket.
Here's the Requestor:
public SocketTest(){
int iterations = 100;
try {
Socket socket = new Socket("localhost", 1212);
ObjectInpu...
How buffered streams are working on the background and how it actually differs and what is the real advantage of using the same?
Another Query,..
Since DataInputSytream is also Byte based, but it is having methods to readLine().. Whats the point in here
I have a problem, which I do not seem to be able to solve...
I do a http download of a file, but the CRC32 of the file on the server and on the client do not match. Also, the file has different size, so obviously I must be doing something wrong... when I download via Firefox, the filesize is ok... so I guess it is somewhere in the client code.
I already found http://stackoverflow.com/questions...
I need to write(append) huge string to flat file using java nio. The encoding is ISO-8859-1.
Currently we are writing as shown below. Is there any better way to do the same ?
public void writeToFile(Long limit) throws IOException{
String fileName = "/xyz/test.txt";
File file = new File(fileName);
FileOutputStream fileOutputStream = new FileOutputStream(file, true);
...
I have a piece of code that reads hell of a lot (hundreds of thousand) of relatively small files (couple of KB) from the local file system in a loop. For each file there is a java.io.FileInputStream created to read the content. The process its very slow and take ages.
Do you think that wrapping the FIS into java.io.BufferedInputStream would make a significant difference?
I am wondering the purpose of BufferedOutputStream, performance gain when using it?
How do I append to large files efficiently. I have a process that has to continually append to a file and as the file size grows the performance seems to slow down as well. Is there anyway to specify a large buffer size with the append
I've seen lots of examples of sending serialized data over sockets in Java, but all I want is to send some simple integers and a string. And, the problem is I'm trying to communicate these to a binary written in C.
So, bottom line: how can I just send some bytes over a socket in Java?
Hallo,
you can give the BufferedOutputStream constructor a int parameter for the buffer size. I my szenario I have one process writing to the disk and on process reading from the disk. Having a default buffer of 8192 bytes causes high fragmentation of big files.
Now I was wondering if I could reduce the fragmentation if I lift the buffer size to 1 Mb.
I think this should work. But does the B...
I am using a BufferedOutputStream to write to a file. While debugging I noticed that the flush operation takes very long even if the OS shows that the file has got the final size.
My theory:
The BufferedOutputStream tell the OS to reserve space in advance? So the OS already shows the file with the full filesize even if the BufferedOutputStream hasn't flushed completly?
Is that correct?
Is there a way to force the temporary files created in a java program in memory? Since I use several large xml file, I would have advantages in this way? Should I use a transparent method that allows me to not upset the existing application.
UPDATE: I'm looking at the source code and I noticed that it uses libraries (I can not change) which requires the path of those files ...
Thanks
I need to write blocks of data (characters) and I don't care about the sequence of those blocks. I wonder what kind of OutputStream I should use to achieve high performance?