View Single Post
  #1 (permalink)  
Old 12-18-2007, 01:51 PM
Mr tuition Mr tuition is offline
Member
 
Join Date: Dec 2007
Posts: 10
Mr tuition is on a distinguished road
how do you get the file type of say a .ZIP file
whats a good method of checking the file is a zip file, apart from checking the extension (toLower)

checking the mime type didn't work as it gave application/octect (as did word docs)

I need to make sure file type is zip, before I do anything with it there are many good java resources for zip, but cant find a good file type check



heres my mime method that didn't work: (or showed there wasn't a difference between mime types for zip files and word files)

PHP Code:
private void listAllzipfiles(String folderlocation){    
            
    
File folder = new File(folderlocation);
    
File[] listOfFiles folder.listFiles();
    
    for (
int i 0listOfFiles.lengthi++) {
      
        
        if (
listOfFiles[i].isFile()) {
        
File file = new File(listOfFiles[i].getName());
        
        
System.out.println("File " listOfFiles[i].getName());
        
String MimeTypeOfFile = new MimetypesFileTypeMap().getContentType(file);
        
System.out.println("Type " MimeTypeOfFile);
      } else if (
listOfFiles[i].isDirectory()) {
        
System.out.println("Directory " listOfFiles[i].getName());
      }
    } 
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Reply With Quote
Sponsored Links