Linux « API « Java I/O Q&A





1. file.createNewFile() creates files with last-modified time before actual creation time    stackoverflow.com

I'm using JPoller to detect changes to files in a specific directory, but it's missing files because they end up with a timestamp earlier than their actual creation time. ...

2. Java - RandomAccessFile (Emulating the Linux tail function)    stackoverflow.com

http://stackoverflow.com/questions/557844/java-io-implementation-of-unix-linux-tail-f has a similar problem; but the solution is not viable for log files that generate about 50-100 lines per second. I have an algorithm that emulates the tail functionality in ...

3. Why executing interactive process with redirected input/output streams causes application being stopped?    stackoverflow.com

I have a console Java program that executes sh -i in a separate process and copies the data between the processes' input/output stream and corresponding System streams:

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

class StreamCopier ...

4. Calling script from java, sigpipe signal received    stackoverflow.com

I am encountering some weird behavior when calling a shell script from a Java process.

Process p = Runtime.getRuntime().exec("mybashscript.sh");
(new StreamGobblerThread(p.getInputStream())).start();
(new StreamGobblerThread(p.getErrorStream())).start();
p.waitFor();
returnValue = p.exitValue();
The StreamGobblerThread just has a run() method that does a ...

5. Why is the output from subprocess in wrong order?    stackoverflow.com

I have a Java program that executes sh in interactive mode as a subprocess. The input is copied from System.in and output is copied to System.out. Everything works fine except that ...

6. Linux: command-line tool to reverse byte order (change endianess)    stackoverflow.com

I'm hacking around in some scripts trying to parse some data written by Javas DataOutputStream#writeLong(...). Since java always seems to write big endian, I have a problem feeding the bytes to ...

7. Why can't I read from /proc in Java using Commons IO FileUtils, but can do so using a plain FileInputStream?    stackoverflow.com

I had a problem with reading /proc/%d/stat files using my Java method copyFiles() (source code below). I have found workaround using similar readProc() method. Now I am wondering what was the problem. Output ...

8. FileChannel.write on Linux produces lots of garbage, but not on Mac    stackoverflow.com

I am trying to limit the amount of garbage produced by my log library, so I coded a test to show me how much memory is FileChannel.write creating. The code below ...

9. InputStreamReader is not properly reading some characters in Linux.    coderanch.com

Hi I have a file that contains the text TEST NAVE SUBJECT I wrote a java program to read this file in RedHat Linux. The java code that reads the file is similar to the below File inputFile = new File(fileName.toString()); FileInputStream in = new FileInputStream(inputFile); LineNumberReader lnr = new LineNumberReader(new InputStreamReader(in)); String streamInput = null; while ((streamInput = lnr.readLine()) != ...





10. filenameFilter in linux directory    coderanch.com

Hi, i've a problem related with filenameFilter. My code is: private boolean compareKunci(String kodeSoal) throws IOException { final String kodeSoalNya = kodeSoal ... FilenameFilter fileNameFilter = new FilenameFilter() { boolean accept1; public boolean accept(File dir, String name) { if (name.startsWith(kodeSoalNya)) { accept1 = true; } else { accept1 = false; JOptionPane.showMessageDialog(null, "No answer available!"); } return accept1; } }; //the result ...

12. Reader - How to read file in Linux    forums.oracle.com

nanoTime. Hmmm, interresting, I was under the impression that the PIC under windows XP was set to interrupt around the millisecond range (but maybe that's not the case); how would java be able to go all the way down to nano seconds other than by averaging multiple execution times (which probably doesn't make sense in most contexts)? And I seriously that ...

13. Serialization and Deserialization in linux    forums.oracle.com

As you are finding out, one should never ever convert binary data, and serialized objects are binary data, to a String without using Base64 or Hex. As a general rule not all byte sequences have a valid character mapping so they cannot be reversibly converted to characters/Strings. On Windows you have just been lucky in that your default character encoding seems ...

14. Difference in DataInputStream.ReadFully in Linux and Window    forums.oracle.com

Hi, I have written a client application that should run in both Windows and Linux client. My client involves communication with the server over socket. The key code that is involved in this question is: DataInputStream.readFully(byte[]) One of the tests done is: While client is connected to the server tester pulled the network cable of the server, so the communication between ...