String sll = path;
//获取字符后四位
if(sll.substring(sll.length()-4, sll.length()).equals(".xls")) {
// 获取Excel文件对象
HSSFWorkbook workBook = new HSSFWorkbook(stream);
}else if(sll.substring(sll.length()-4, sll.length()).equals(".xlsx")) {
//xlsx
HSSFWorkbook workBook = new HSSFWorkbook(stream);
}else if(sll.substring(sll.length()-5, sll.length()).equals(".docx")) {
//用来读取docx文件
XWPFDocument doc = new XWPFDocument(stream);
}else if(sll.substring(sll.length()-4, sll.length()).equals(".doc")){
//doc
HWPFDocument doc = new HWPFDocument(stream);
}else if(sll.substring(sll.length()-4, sll.length()).equals(".pdf")) {
//pdf
PDDocument pd = PDDocument.load(stream);
}