是否有可能在黑莓使用J2ME保存BBM聊天在一个文本文件 [英] Is it possible to save BBM chat in a text file using J2ME in Blackberry

查看:300
本文介绍了是否有可能在黑莓使用J2ME保存BBM聊天在一个文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,我可以使用 javax.microedition.io.file.FileConnection 为所需的目的。但我需要一个例子。
为什么我不能使用 java.io.FileOutputStream中的,并用这块code,而不是:

As far as i know, i can use javax.microedition.io.file.FileConnection for the required purpose. But i need an example. Why i can't i use java.io.FileOutputStream, and use this piece of code instead:

FileOutputStream fout;      

        try
        {
            // Open an output stream
            fout = new FileOutputStream ("myfile.txt");

            // Print a line of text
            new PrintStream(fout).println ("I'm making an app on android!");

            // Close our output stream
            fout.close();       
        }
        // Catches any error conditions
        catch (IOException e)
        {
            System.err.println ("Unable to write to file");
            System.exit(-1);
        }

请解释一下。谢谢

推荐答案

您发布的snipet使用JavaSE的班,不提供黑莓手机。

The snipet you posted uses JavaSE classes, not available in BlackBerry.

您需要做的:

FileConnection fconn = (FileConnection)Connector.open("file:///CFCard/myfile.txt");
OutputStream os = fconn.openOutputStream();
os.write("I'm making an app on BB!".getBytes());
os.flush();
os.close();
fconn.close();

我已经跳过异常控制,使片段更简洁,但你必须要关心他们像往常一样。

I've skipped exception control to make snippet less verbose, but you'll have to care about them as usual.

这篇关于是否有可能在黑莓使用J2ME保存BBM聊天在一个文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆