문제

I am trying to read file headers using java, I want to get file type(image, audio whatever). I have tried many examples but nothing seems to work. I tried preon and no luck, can some one tell me how to read file headers using preon or some other Java apis thanks...

도움이 되었습니까?

해결책

Use mime-util's MagicMimeMimeDetector:

detector.getMimeTypes(file)

다른 팁

 File f = new File(filepath);
 System.out.println("Mime Type of " + f.getName() + " is " +  
 new MimetypesFileTypeMap().getContentType(f));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top