public static void getVidio(String path){
 File fil = new File(path);
 File[] files = fil.listFiles();
 count++;
 if(count > 15000){
 System.out.println(count);
 return;
 }
 getVidio(path);
 }
 
Exception in thread "main" java.lang.StackOverflowError请问怎么处理这个问题啊,我想做一个全盘扫描,扫描文件多了,就报这个错误。

解决方案 »

  1.   

    内存溢出
    楼主这个count++ 之前 是否该加个判断语句 ?
      

  2.   

    Thrown when a stack overflow occurs because an application recurses too deeply. public static void getVidio(String path){//
    File fil = new File(path);
    File[] files = fil.listFiles();
    count++;
    if(count > 15000){
    System.out.println(count);
    return;
    }
    getVidio(path); //这不是死循环吗
    }
      

  3.   

    没有死循环啊,我加了这个判断的
    if(count > 15000){
    System.out.println(count);
    return;
    }
      

  4.   

    java.lang.StackOverflowError就是栈溢出,是java虚拟机抛出的错误,不是你程序问题,一般是死循环导致的,自己检查一下程序吧
      

  5.   

    线程占用的内存大小是固定的,java5之前默认是256K吧、尝试着-Xss增大其值. 
      

  6.   

    public static void getVidio(String path){
    File fil = new File(path);
    File[] files = fil.listFiles();
    count++;
    if(count > 15000){
    System.out.println(count);
    return;
    }
    getVidio(path);
    }
    看不明白,为什么path路径不会改变的?
      

  7.   

    首先,你那个fil.listFiles();要加个if语句,判断是不是文件夹,如果是在得天fil.listFiles();
    for(File f:files){getVidio(f.getName())}
    然后,else不是文件夹,就把它统计count++;return;
         这是才递归,你写的那个递归,我还真看不懂,可能我技术太差吧,看不懂那么深的逻辑!
      

  8.   

    死循环就说不上了,每次调用这个方法,都会count++;if条件满足了就出来了。。