从以下程序中的OutputStream获取字符串?

时间:2015-01-12 12:54:19

标签: android

从下面的程序

中的OutputStream获取字符串
public class MainActivity extends ActionBarActivity {

    PDDocument pd;
    BufferedWriter wr;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String path = Environment.getExternalStorageDirectory()
                + "/Demo/Test.pdf";
        try {
            File input = new File(path); // The PDF file from where you would
                                            // like to extract
            File output = new File(Environment.getExternalStorageDirectory()
                    + "/Test/test.txt"); // The text file where you are going to
                                            // store the extracted data
            pd = PDDocument.load(input);
            PDFTextStripper stripper = new PDFTextStripper();
            int endpage = pd.getNumberOfPages();
            stripper.setStartPage(1); // Start extracting from page 1
            stripper.setEndPage(endpage); // Extract till page 1
            wr = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(output)));
            stripper.writeText(pd, wr);

            if (pd != null) {
                pd.close();
            }
            // I use close() to flush the stream.
            wr.close();
        }

        catch (Exception e) {
            e.printStackTrace();
        }
    }
}

朋友们,我想要上面代码中的文本(字符串)..它存储在哪个变量中? 我是android的新手,所以请原谅并给出一个很好的解决方案的家伙,在此先感谢。

0 个答案:

没有答案