다양한 종류의 파일 을 보 여 주 는 데 도움 이 되 는 글 입 니 다.
14462 단어 문건
http://www.cnblogs.com/hibraincol/archive/2010/09/16/1828502.html
Android 에서 파일 형식 과 MIME 의 일치 표
배경 설명:
MIME: 전 칭 Multipurpose Internet Mail Extensions, 다기 능 인터넷 메 일 확장 서비스.이것 은 다 용도 인터넷 메 일 확장 프로 토 콜 로 1992 년 에 최초 로 메 일 시스템 에 응용 되 었 으 나 나중에 브 라 우 저 에 도 응용 되 었 다.MIME 형식 은 어떤 확장자 의 파일 을 프로그램 으로 여 는 방식 으로 설정 하 는 것 입 니 다. 이 확장자 파일 이 접근 할 때 브 라 우 저 는 자동 으로 지정 한 프로그램 으로 엽 니 다.클 라 이언 트 가 사용자 정의 한 파일 이름과 일부 미디어 파일 열기 방식 을 지정 하 는 데 많이 사 용 됩 니 다.
안 드 로 이 드 에 서 는 파일 의 MIME 형식 을 통 해 어떤 프로그램 이 이 파일 을 처리 할 수 있 는 지 판단 하고 그 중의 한 프로그램 을 사용 합 니 다 (선택 할 수 있 는 프로그램 이 여러 개 있 으 면 사용 자 는 하 나 를 지정 해 야 합 니 다).
안 드 로 이 드 자원 관리자 (파일 브 라 우 저) 를 쓸 때 자원 관리자 에서 파일 을 여 는 작업 을 하고 싶 습 니 다. 이 때 파일 의 MIME 형식 이 필요 합 니 다.
배경 분할 선
실현 방법:
/** * MIME 。 * @param file */ private String getMIMEType(File file) { String type="*/*"; String fName=file.getName(); // "." fName 。 int dotIndex = fName.lastIndexOf("."); if(dotIndex < 0){ return type; } /* */ String end=fName.substring(dotIndex,fName.length()).toLowerCase(); if(end=="")return type; // MIME MIME 。 for(int i=0;i<MIME_MapTable.length;i++){ if(end.equals(MIME_MapTable[i][0])) type = MIME_MapTable[i][1]; } return type; } /** * * @param file */ private void openFile(File file){ //Uri uri = Uri.parse("file://"+file.getAbsolutePath()); Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // intent Action intent.setAction(Intent.ACTION_VIEW); // file MIME String type = getMIMEType(file); // intent data Type 。 intent.setDataAndType(/*uri*/Uri.fromFile(file), type); // startActivity(intent); } 이제 MIME 형식 과 파일 형식의 일치 표 가 하나 부족 합 니 다.
"파일 형식 - MIME 형식" 의 일치 표:
// MIME private final String[][] MIME_MapTable={ //{ , MIME } {".3gp", "video/3gpp"}, {".apk", "application/vnd.android.package-archive"}, {".asf", "video/x-ms-asf"}, {".avi", "video/x-msvideo"}, {".bin", "application/octet-stream"}, {".bmp", "image/bmp"}, {".c", "text/plain"}, {".class", "application/octet-stream"}, {".conf", "text/plain"}, {".cpp", "text/plain"}, {".doc", "application/msword"}, {".exe", "application/octet-stream"}, {".gif", "image/gif"}, {".gtar", "application/x-gtar"}, {".gz", "application/x-gzip"}, {".h", "text/plain"}, {".htm", "text/html"}, {".html", "text/html"}, {".jar", "application/java-archive"}, {".java", "text/plain"}, {".jpeg", "image/jpeg"}, {".jpg", "image/jpeg"}, {".js", "application/x-javascript"}, {".log", "text/plain"}, {".m3u", "audio/x-mpegurl"}, {".m4a", "audio/mp4a-latm"}, {".m4b", "audio/mp4a-latm"}, {".m4p", "audio/mp4a-latm"}, {".m4u", "video/vnd.mpegurl"}, {".m4v", "video/x-m4v"}, {".mov", "video/quicktime"}, {".mp2", "audio/x-mpeg"}, {".mp3", "audio/x-mpeg"}, {".mp4", "video/mp4"}, {".mpc", "application/vnd.mpohun.certificate"}, {".mpe", "video/mpeg"}, {".mpeg", "video/mpeg"}, {".mpg", "video/mpeg"}, {".mpg4", "video/mp4"}, {".mpga", "audio/mpeg"}, {".msg", "application/vnd.ms-outlook"}, {".ogg", "audio/ogg"}, {".pdf", "application/pdf"}, {".png", "image/png"}, {".pps", "application/vnd.ms-powerpoint"}, {".ppt", "application/vnd.ms-powerpoint"}, {".prop", "text/plain"}, {".rar", "application/x-rar-compressed"}, {".rc", "text/plain"}, {".rmvb", "audio/x-pn-realaudio"}, {".rtf", "application/rtf"}, {".sh", "text/plain"}, {".tar", "application/x-tar"}, {".tgz", "application/x-compressed"}, {".txt", "text/plain"}, {".wav", "audio/x-wav"}, {".wma", "audio/x-ms-wma"}, {".wmv", "audio/x-ms-wmv"}, {".wps", "application/vnd.ms-works"}, //{".xml", "text/xml"}, {".xml", "text/plain"}, {".z", "application/x-compress"}, {".zip", "application/zip"}, {"", "*/*"} };
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
python 3 - 파일 수정 - 셸 의 sed 와 유사 한 기능 구현# Auther: Aaron Fan r, ( )。 w, 。【 ; ; ; , 】 a, 。【 ; ; ;】 :f.close() python 。 , str() 。 #r ( ) f = open('yesterday',enc...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.