/** * 跳转sdcard * @param sel 是 onActivityResult中 requestCode的值,自定义 */ private void selcetFile(int sel) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(intent, sel); }
//返回值处理 @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (data == null) return; String uri = data.getData().toString(); setText("文件路径:" + uri); }
String --> InputStream
ByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes());
InputStream --> String
String inputStream2String(InputStream is){
}
File --> InputStream
InputStream in = new FileInputStream(file);
InputStream --> File
public void inputstreamtofile(InputStream ins,File file){
}