请教在JSP中如何判断一个文件的类型?

解决方案 »

  1.   

    先做字符截取filename = filename.subString(filename.lastOfIndex("."))
    再做字符判断就可以了
      

  2.   

    lz是不是要判断.txt->文本文件?假如你是Windows的话,这个能根据你服务器(不是客户端)上设置的文件类型描述    FileSystemView fsw = FileSystemView.getFileSystemView();
        File file = File.createTempFile("abc", ".txt");
        
        String description = fsw.getSystemTypeDescription(file);
        System.out.println(description);理论上对linux等系统也有用。
      

  3.   

    RPGboy_gxn() 显示出错!!!path1 = request.getParameter("path1");
    path_1 = path1.subString(path1.lastOfIndex("."));有没有只截取字符串最后几个字母的方法啊???!!!!!!!!!!!!!
      

  4.   

    path_1 = path1.subString(path1.lastOfIndex("."),path1.length);
      

  5.   

    报什么String 那块出问题了????
      

  6.   

    path1 = request.getParameter("path1");
    //这里是不是没做NULL处理?
    if(path1==null)
      path1="";
    path_1 = path1.subString(path1.lastOfIndex("."));如果还有错把错贴出来我看看
      

  7.   

    String fileName = "abcd.txt";   //文件名
    String str = fileName.substring(fileName.lastIndexOf(".")+1);   // str = 文件后缀名