用ulimit -n 命令查看,结果是256, 这说明进程能打开的最大文件数不超过256个 
但下面的java程序却能成功打开10000多个, 这是什么原因? import java.io.*; public class openfile{ 
    public static void main(String[] args) 
    { 
        PrintWriter[] bw = new PrintWriter[15000];         try{ 
             for (int i=0; i < bw.length; i++) 
             { 
                 bw[i] = new PrintWriter(new BufferedWriter(new FileWriter("test"+i))); 
                 bw[i].println("Hello World! " + i); 
                 bw[i].close(); 
             }  
              
             //这个循环可以成功地打开15000个文件  
             for (int i=0; i < bw.length; i++) 
             { 
                 BufferedReader br = new BufferedReader(new FileReader("test" + i)); 
                 String str = br.readLine(); 
                 System.out.println("read file test" + i + " : " + str); 
                  
                 try{ 
                     if (i % 256 == 0) Thread.sleep(1000); 
                 }catch(Exception e){} 
             } 
             String s = "test0"; 
             File f = new File(s); 
             if (f.exists()) 
             { 
                 Process pro = Runtime.getRuntime().exec("/opt/swe/bin/gzip " + "test0"); 
                 pro.waitFor();                  System.out.println("exit value: " + pro.exitValue()); 
             } 
             else 
                 System.out.println("file not exsit");         } 
        catch(Exception e) 
        { 
            System.out.println("exception! " + e.getMessage()); 
        }         System.out.println("Bye..."); 
    }