Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6553826

File{Input,Output}Stream.<init> throws IOException for socket files, on Linux/Unix

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • core-libs
    • None
    • generic
    • linux

      There are several types of files in Unix world: regular files, directories, char and block devices, named pipes and socket files. I'm trying to work with a socket file to communicate with another (non-Java) process. Method exists() for such file returns true, however when I try to create a corresponding FileInputStream or FileOutputStream I get an IOException: "No such device or address".

      To reproduce the problem, launch the following test (with a modified file name):

      import java.io.*;

      public class TestSocketFile
      {
        public static void main(String[] args)
          throws IOException
        {
          File f = new File("FILENAME");
          System.err.println("File exists: " + f.exists()); // <-- returns true
          FileInputStream fin = new FileInputStream(f); // <-- IOException is thrown
          FileOutputStream fout = new FileOutputStream(f); // <-- IOException is thrown
        }
      }

      (Just an example of socket file: when running X server, get the value of $XSESSION_MANAGER environment variable and look at the 'local/hostname:/path/to/file' entry - on my desktop it points to something like /tmp/.ICE-unix/12345 which is a socket file).

            iris Iris Clark
            art Artem Ananiev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: