android pdf解析

android pdf解析源码链接地址 Androidpdf解析packagecom.jyx.pdfpasre;importjava.io.IOException;importjava.io.InputStream;importjava.lang.reflect.InvocationTargetException;importandroid.app.Activity;importandroid.c

源码链接地址 Android pdf解析

package com.jyx.pdfpasre;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import android.app.Activity;
import android.content.Context;
import android.os.Environment;
import android.os.storage.StorageManager;

public class ServiceMothed {
	public static String SDCARDPATH = Environment.getExternalStorageDirectory()
			.getPath();
	public static String SDCARDPATHEXS;//
	public static String File_PATH = SDCARDPATH + "/pdftest/";
	public static String Filezip_PATH = SDCARDPATH + "/pdftest";
	public static ServiceMothed servicemothed = null;

	public static ServiceMothed init() {
		if (servicemothed == null) {
			servicemothed = new ServiceMothed();
		}
		return servicemothed;
	}

	public void GetSdcardPath(Activity activity) {
		if (getAndroidSDKVersion() > 13) {
			StorageManager sm = (StorageManager) activity
					.getSystemService(Context.STORAGE_SERVICE);
			try {
				String[] paths = (String[]) sm.getClass()
						.getMethod("getVolumePaths", null).invoke(sm, null);
				if (paths != null) {
					if (paths.length != 0) {
						for (int i = 0; i < paths.length; i++) {
							if (!SDCARDPATH.equals(paths[i].trim())) {
								if (Environment.getExternalStorageState()
										.equals(Environment.MEDIA_REMOVED)) {
								} else {
									SDCARDPATH = paths[0].trim();
								}
							}
						}
					}
				} else {
				}
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			} catch (InvocationTargetException e) {
				e.printStackTrace();
			} catch (NoSuchMethodException e) {
				e.printStackTrace();
			}
		} else {
			if (!Environment.getExternalStorageState().equals(
					Environment.MEDIA_REMOVED)) {
			}
		}
	}

	public int getAndroidSDKVersion() {
		int version = 0;
		try {
			version = Integer.valueOf(android.os.Build.VERSION.SDK);
		} catch (NumberFormatException e) {
		}
		return version;

	}

	public String InputStreamToString(InputStream in) throws IOException {
		StringBuffer out = new StringBuffer();
		byte[] b = new byte[1026*4];
		for (int n; (n = in.read(b)) != -1;) {
			out.append(new String(b, 0, n, "GBK"));
			;
		}
		return out.toString();
	}
}

今天的文章android pdf解析分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/27539.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注