The file InputStream is null

Hello friends,

I'm uploading the wav file and I'm getting inputstream of file vacuum...

I send you the part of the code...

fconnWav = (FileConnection) Connector.open ("file:///SDCard/BlackBerry/voicenotes/"+jobName+"_1.wav", Connector.READ_WRITE);

If (! fconnWav.Exists ())

{Dialog.alert ("gall did not exist");

}

int length = (int) fconnWav.fileSize ();

Dialog.Alert (Integer.toOctalString (Length));

InputStream fileInputStream = fconnWav.openInputStream ();

If (fileInputStream.available () == 0)

{Dialog.alert ("empty stream");

}

Here, fileinput stream is empty when the file size is 4441...

How is it possible...

You declare that it is null because the layout is 0?  In general, I would recommend that ignore available as a measure of data in a file, do not forget it is only meant to match the amount available without blocking (i.e.. Immediately).  So I'm not surprised is is 0 in this case, but this does not mean that you wouldn't be able to read the bytes.  Try to read and see.

Tags: BlackBerry Developers

Similar Questions

  • move the cursor at the beginning of the file (InputStream)

    Hello! I read a file (using InputStream) and necessary move the slider at the beginning of the file (to be able to search inside the file, moving at the beginning and then jump bytes). I'm targeting 4.5 OS. Is it possible to do? Can I reopen it the file? (is it slow? is this a bad idea?)

    Thank you very much!

    silencer

    Call InputStreamReader.mark (readlimit) in early reading. Then call InputStreamReader.reset () whenever you want to reset the position of the stream of input to its original position, when the brand was called.

  • get the Inputstream of the file jasper from a specific path

    Hello

    I use jdev 11.1.1.7.0

    I need to get the InputStream of the file jasper in my application to view the report in PDF format. I do this by following codes:

    
    ServletContext context = getContext();
    InputStream inputstream = context.getResourceAsStream(repPath); //  repPath = "reports/reportName.jasper"
    
    
    
    

    whereas the repPath is the folder that exist in the current application (ViewController\public_html\reports\reportName.jasper)

    but I want to put all in a specific folder as "d:\reports" and all reports call for applications of this path.

    but when I put repPath = "d://reports//reportName.jasper", the variable in the code below inputstream is null

    
    InputStream inputstream = context.getResourceAsStream(repPath); //  repPath = "d://reports/reportName.jasper"
    
    
    
    

    I need to have a specific for all reports path, because some reports can be called from many applications, can someone help me?

    Habib

    Concerning

    getResourceAsStream() return resources compared to the current ClassLoader.

    You can use something like:

    inputstream = new FileInputStream(repPath);
    

    Dario

  • Read and write the empty file - InputStream

    Hi all

    I have a problem with the playback of a file.

    This is my code:

    I create my file and put my datas:

    try {
            String filePath = "file:///store/home/user/locations.txt";
        FileConnection filecon =(FileConnection)Connector.open(filePath,Connector. READ_WRITE);
    
        // Always check whether the file or directory exists.
        // Create the file if it doesn't exist.
        if(!filecon.exists()) {
            filecon.create();
        }
    
        OutputStream out = filecon.openOutputStream();
    
        out.write(data.getBytes());
    
        filecon.close();
    
    } catch(IOException ioe) {
    
        Dialog.alert(ioe + "");
    
    }
    

    Then I want to read my data but my inputStream is empty and I don't understand why...

    String filePath = "file:///store/home/user/locations.txt";
    FileConnection filecon = (FileConnection)Connector.open(filePath,Connector. READ_WRITE);
    
    // Always check whether the file or directory exists.
    // Create the file if it doesn't exist.
    if(!filecon.exists()) {
        filecon.create();
    }
    
    InputStream in = filecon.openInputStream();
    InputStreamReader  reader = new InputStreamReader(in);
    
    StringBuffer sb = new StringBuffer();
    
    final char[] buf = new char[1024];
    int len;
    while ((len = reader.read(buf)) > 0) {
        sb.append(buf, 0, len);
    }
    
    data = sb.toString();
    

    Thanks for your help...

    Welcome to the forum.

    Can't see anything obviously wrong.

    I suggest for now you change to use the SD card instead of the store and run in the Simulator with the SD card simulated as a directory.  You can browse the Windows directory and if, in fact, the file is created as expected.

  • Validate the file browse point is not null?

    Hello, using APEX 5.0.1. I have a process that needs to run in case a file browse is not null - validation of the PL/SQL Expression. * The file storage type is: BLOB column specified in the attribute of the Source element. for example: P14_STATUS_ID_CURRENT_VALUE = 0 AND: P14_IS_CANCELLED = ' only AND: P14_FILEBROWSE_ITEM IS NOT NULL, even if I download the file, the validation fails! ??? Then I tried this validation, but no result, select FILENAME from wwv_flow_files where name =: p$ _fname and: P14_STATUS_ID_CURRENT_VALUE = 0 AND: P14_IS_CANCELLED = 'n') is this a bug? is there a work around?

    Solved: It should be: dbms_lob.getlength(:P14_FILEBROWSE_ITEM) > 0

  • reading and writing to the file on SD card

    I am currently using this code to read and write to files (credit is not because of me - I found these on the Board somewhere):

       private void writeFile(String data, String filePath)
        {
            try
            {
                FileConnection conn = (FileConnection)Connector.open(filePath,Connector.READ_WRITE);
                if (!conn.exists())
                {
                    Dialog.alert("No File Present Click to Create");
                    conn.create();
                }
    
                OutputStream out = conn.openOutputStream();
                byte[] b = data.trim().getBytes();
                String sb = new String(b);
                System.out.println("Bytes to String: " + sb);
    
                if(sb.length() == 0 )
                    System.out.println("String length is zero");
                else
                    System.out.println("String length is not zero" + sb.length());
    
                if(conn.canWrite())
                {
                    Dialog.alert("Writing");
                    out.write(b,0,sb.length());
                }
                else
                    System.out.println("Cannot write to this file");
    
                System.out.println("File Size is : "+ conn.fileSize());
                out.flush();
                out.close();
            }
            catch(Exception io)
            {
                test.setText("Exceptino Thrown from File" +io);
            }
    
        }
    
        private String readFile(String filePath)
        {
            try
            {
                FileConnection fconn = (FileConnection)Connector.open(filePath, Connector.READ);
                if (fconn.exists())
                {
                    InputStream input = fconn.openInputStream();
    
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    int j = 0;
                    while((j=input.read()) != -1) {
                        baos.write(j);
                    }
                    byte[] data = baos.toByteArray();
                    input.close();
    
                    String output = new String(data);
                    System.out.println("Output" + output);
    
                    fconn.close();
                    return output;
                }
                else
                {
                    System.out.println("File does not exist");
                    fconn.close();
                    return null;
                }
            }
            catch (Exception ioe) {
    
               System.out.println("Error:   " + ioe.toString());
               return null;
            }
    
        }
    

    When I try to write a string to a file and then read it again, I get a NullPointerException. When I check the folder that mimicks card SD card on my pc, there is no file created. is the above code ok?

    P.S. I use a simulator of the OS 5.0 and the SD card directory is configured to be somewhere on my desk.

    It is incredibly baroque and inefficient code for a simple job; be happy that you do not claim credit for it.

    A problem may be that the FileConnection in writeFile is not closed. I would rewrite the mess like this (leaving a part of the diagnostic output):

    private void writeFile(String data, String filePath) {  data = data.trim();  OutputStream out = null;  FileConnection conn = null;  try {     conn = (FileConnection) Connector.open(filePath,Connector.READ_WRITE);    if (!conn.exists()) {      conn.create();    }    OutputStream out = conn.openOutputStream();    // it might be advisable to specify an encoding on the next line.    out.write(data.getBytes());  } catch (Exception io) {    test.setText("Exception Thrown from File " + io);  } finally {    if (out != null) try { out.close(); } catch (IOException ignored) {}    if (fconn != null) try { fconn.close(); } catch (IOException ignored) {}  }}
    
    private String readFile(String filePath) {  String result = null;  InputStream input = null;  FileConnection conn = null;  try {    fconn = (FileConnection) Connector.open(filePath, Connector.READ);    if (fconn.exists()) {      input = fconn.openInputStream();      byte[] bytes = IOUtilities.streamToBytes(input);      // it might be advisable to specify an encoding on the next line.      result = new String(bytes);    } else {      System.out.println("File does not exist");    }  } catch (Exception ioe) {    System.out.println("Error: " + ioe.toString());  } finally {    if (input != null) try { input.close(); } catch (IOException ignored) {}    if (fconn != null) try { fconn.close(); } catch (IOException ignored) {}  }  return result;}
    
  • LaserJet MFP M125nw Pro: #2 cannot install LaserJet MFP M125nw Pro because of the error "the system cannot find the file specified."

    Hello

    I struggled in the last 2 days to install my new all in one Pro LaserJet MFP M125nw. I tried almost all the stuff Google and this community offered under the heading "the system cannot find specified file", without success. My frustration is huge because I'm not really a novice when it comes to solve similar problems.

    Here is what I do and what is happening:

    I downloaded the latest version of the complete software for XP HP offers through their Web site. I tried to install the drivers through the install wizzard, then manually (used for the files in the folder 7ZXXX in the directrory temp) but no matter what I do, I get the same error again and again. In fact XP recognizes the printer and the scanner, it installs even drivers for the scanner and it works but after maybe 50 attempts in different ways, XP couldn't install the printer driver.

    Here are a few screenshots:

    http://i.imgur.com/GuGmTP2.jpg

    http://i.imgur.com/OZyFuz0.jpg

    http://i.imgur.com/2O0J3aE.jpg

    http://i.imgur.com/exAy5RG.jpg

    It's the event viewer:

    Event type: error
    Event source: MsiInstaller
    Event category: no
    Event ID: 11721
    Date: 26.6.2015 г.
    Time: 18:47:40
    User: HPREDDY-79F942C14\Yasko
    Computer: YASKO-79F942C14
    Description:
    The description for the event (11721) in Source (MsiInstaller) ID is not found. The local computer may not have the information necessary registry or message DLL files to display messages from a remote computer. You may be able to use the option/auxsource = flag to retrieve this description; For more information, see Help and Support. The following information is part of the event: product: HP Support Solutions Framework - error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your provider to support personal or package. Action: UnregisterAclmControl, location: C:\Program Files\Hp\Common\AclmControl.exe, command: /unreg; (NULL); (NULL); (NULL); (NULL);.
    Data :
    0000: 7 b 46 43 33 43 32 42 37 {FC3C2B7
    0008: 37 36 38 30 30 34 7-6800-4 2d 2d
    0010: 38 43 36 41 31 35 44 8 C 6-A15D 2D
    0018: 2D 39 44 31 30 33 31 31 - 9 D 10311
    {0020: 33 30 43 31 36 7 Dec 30 16}

    =====================================================================================

    Event type: error
    Event source: app error
    Event category: no
    Event ID: 1000
    Date: 26.6.2015 г.
    Time: 18:56:14
    User: n/a
    Computer: YASKO-79F942C14
    Description:
    Failing application plugin - container.exe, version 38.0.5.5623, failed module mozalloc.dll, version 38.0.5.5623, address 0x00001aa1 failure.

    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
    Data :
    0000: 41 70 70 6 c 69 63 61 74 Applicat
    0008: 69 6th 6f 20 46 61 69 6 c ion Fail
    0010: 75 72 65 20 20 70 6 c 75 plu ure
    0018: 67 69 6th 2d 63 6f 6 74 gin-cont
    0020: 61 69 6 65 2nd 72 65 78 ainer.ex
    0028: 65 20 33 38 2e 30 2e 35 e 38.0.5
    0030: 2nd 35 36 32 33 20 69 6th en.5623
    0038: 20 6 d 6f 7 a 61 6 c 6 c 6f mozallo
    0040: 63 2e 64 6 c 6 c 20 33 38 38 c.dll
    0048: 30 2nd 2nd 2nd 35 35 36 32.0.5.562
    0050: 33 20 61 74 6f 20 66 66 3-off
    0058: 73 65 74 20 30 30 30 30 put 0000
    0060: 31 61 61 31 0a 1aa1 0D...

    Found the solution. The problem was that I had Microsoft .net Framework 4. After that I went back to 3.5, the driver through the installation went perfectly. Thank you guys for the effort.

  • The macro was interrupted because of an error, but the file remains open.

    I have a file that is opened by a macro Excel (VBA).  The macro was interrupted because of an error, but the file remains open.  I can't find any way to close.  The file is located on a server, not my hard drive.

    This is the code that opens the file/workbook

    Dim fso As Object
    Set fso = VBA. CreateObject ("Scripting.FileSystemObject")
    TT = fso. CopyFile (Sheet1.Cells (2: 17) & "List1.xlsm", Sheet1.Cells (2: 17) & "Merge1.xlsm", True)

    'bind to the data source document.
    wordDoc.MailMerge.MainDocumentType = wdFormLetters
    wordDoc.MailMerge.OpenDataSource Name: = Sheet1.Cells (2, 17) & "Merge1.xlsm", _
    SQLStatement: = "SELECT * FROM ' Sheet1$ ' WHERE sort_order IS NOT NULL" "
     
    "fill the body of the document with the fields in the data source."
     
    "first of all get the field names in the spreadsheet
    Set wkbk = Excel.Workbooks.Open (Sheet1.Cells (2: 17) & "Merge1.xlsm")
    Set headerRange = Excel.Range (wkbk. Sheets ("Sheet1"). Wkbk, Range("B1"). Sheets ("Sheet1"). Range ("IV1"). End (xlToLeft))
    headerValues = Application.Transpose (headerRange.Value)
    wkbk. Close False

    This issue is beyond the scope of this site (for consumers) and to be sure, you get the best (and fastest) reply, we have to ask either on Technet (for IT Pro) or MSDN (for developers)
    *
  • Attach the file to your e-mail via mailto + invocation framework

    I am tryng to attach a file to an e-mail message using the mailto syntax.

    The email app is opened by the framework of the call

    MailSubject = "Test"
    MailBody = "Hello!";
    
    // create handler invocation
    navigator_invoke_invocation_t *invoke = NULL;
    navigator_invoke_invocation_create(&invoke);
    
    // setting the browser as target
    navigator_invoke_invocation_set_target(invoke, "sys.pim.uib.email.hybridcomposer");
    
    // set invocation action
    navigator_invoke_invocation_set_action(invoke , "bb.action.OPEN, bb.action.SENDEMAIL");
    
    // Setting URI
    navigator_invoke_invocation_set_uri(invoke , ("mailto:[email protected][email protected]&subject=" + MailSubject + "&body=" + MailBody + "&attachment=" + "file:///accounts/1000/shared/print/file").toAscii().data() );
    
    // invoke the target
    navigator_invoke_invocation_send(invoke);
    
    // clean up resources
    navigator_invoke_invocation_destroy(invoke);
    

    I tried to delete file:/// and put / alone but doesn't either.
    The file is located in the shared folder and I know is the only way to attach a file to an email.

    https://developer.BlackBerry.com/native/documentation/core/email.html

    There are a few examples, but none of them have pre-compiled field such cc + object + body + attachments together.

    Can someone help me?

    Thank you

    I went from Json to QVariantMap and no, it works without problem. Here is the code:

        bb::system::InvokeManager InvokeManager;
        bb::system::InvokeRequest InvokeRequest;
    
        QVariantMap EmailData;
        QVariantMap EmailDataWrapper;
    
        EmailData["to"] = "[email protected]";
        EmailData["cc"] = "[email protected]";
        EmailData["subject"] = "MailSubject";
        EmailData["body"] = "MailBody";
        EmailData["attachment"] =  "/accounts/1000/shared/print/file";
    
        EmailDataWrapper["data"] = EmailData;
    
        InvokeRequest.setTarget("sys.pim.uib.email.hybridcomposer");
        InvokeRequest.setAction("bb.action.COMPOSE");
        InvokeRequest.setMimeType("message/rfc822");
        InvokeRequest.setData(bb::PpsObject::encode(EmailDataWrapper , &bool_result) );
    
        InvokeManager.invoke(InvokeRequest);
    
  • Problem with the file opened in the application via InvokeRequest

    Hello

    my application opens the file and reads its binary content. I have a small problem to open a file from a navigation or an attachment.

    But first here's how my app works. I have a signal/slot-connection in my applicationUI constructor:

    ApplicationUI::ApplicationUI(bb::cascades::Application *app) : QObject(app), m_invokeManager(new bb::system::InvokeManager(this)) {
    
      bool ok;
    
      // Since the variable is not used in the app, this is added to avoid a
      // compiler warning.
      Q_UNUSED(ok);
    
      ok = QObject::connect(m_invokeManager, SIGNAL(invoked(const bb::system::InvokeRequest&)), this, SLOT(handleInvoke(const bb::system::InvokeRequest&)));
    
    }
    

    So if the user clicks on a file it can open in the following C++ function:

    void ApplicationUI::handleInvoke(const bb::system::InvokeRequest& request) {
    
        QString workingDir = QDir::currentPath();
    
    // Initiate the appropriate target based on the invoke.target-key
        if (request.target() == "com.myapp.card.previewer") {
    
            m_uri = request.uri().toString();
    
            QString FileToOpen = m_uri.replace(QString("file://"), QString(""));
    
            bb::cascades::Page* PageToOpen = ApplicationUI::doLoadPageDetails(FileToOpen);
    
            if (PageToOpen != NULL) {
                initPreviewerUI();
            } else {
                ShowToast("FEHLER! Seite kann nicht geladen werden");
            }
        }
    }
    

    The doLoadPageDetails () - function creates a page and filled with binary content of reading a file. If the file contains errors or is corrupted an exception is thrown.

    And here is my problem. When I opened a file corrupted first the screen becomes darker before opening the app. The I get error messages, exactly as I want. But the screen stays dark. I can't take another navigation element. Also, I can't use the back button. The only solution is to wipe the screen and then use the active frame to close the filebrowser and reopen it.

    That I can't use it with attachments to emails. When I open on and the screen is dark, I can't close the view for emails. So to see the mails again I have to restart the BB decive.

    I'm not fluent in English, but I hope you understand my problem. Is it possible to cancel the invokeRequest when the file is corrupted? Or what can I do here?

    Well, the solution was to use a Toast message but the dialog box. Because that prevents the application and I can't and shows just the message, with the button on this dialog box, I cannot tell the app to close.

  • Detects the MIME type of the file

    Hello

    Is it possible to get the MIME type of the file extension or content?

    Thank you

    Seems that I found the solution: passing NULL as the MIME type when creating an attachment

    Attachment(NULL, attachmentName, attachmentUrl)
    
  • Copy the file in "res" to the file system

    Hello

    I am trying to copy a file from my .cod file in the file system, so I can crush it etc. However, I can't get the file to write. This is the code that I use in this time, I found it while searching for the community.

    try {}
    FileConnection fc = Connector.open("file:///store/home/holidays.xml") (FileConnection);
    If (! fc.exists ()) {}
    FC. Create();
    OutputStream os = fc.openOutputStream ();
    InputStream is = getClass().getResourceAsStream("/xml/holidays.xml");
    Byte [] buf = new byte [1024];
    int len = 0;
    While ((len = is.read (buf)) > 0) {}
    OS. Write (buf, 0, len);
    }
    is. Close();
    OS. Close();
    Add (new LabelField ("" wrote leader. "'));
    }
    } catch (IOException e) {}
    e.printStackTrace ();
    }

    It is in the constructor of the form. When I run the app, I do not get "the file was written., just a white screen. Any suggestions on what I am doing wrong?

    Thank you in advance,

    Ben

    Thanks for the tips,

    I finally understood what was going on; something about reading the xml/holidays.xml file didn't work at all. In the end, I read a holidays.txt file in an xml file in the file system. This isn't a good solution, but it works fine now.

    Thank you

    Ben

  • New line characters in the file writing

    I use the following function to write text in the file

    public void DebugLog (String strTxt)
    {
    System.Err.println (strTxt);
    System.Err.println("\r\n");
       
    Try
    {
    String iFileName = "file:///SDCard/BlackBerry/pictures/Debug.log";
    FileConnection fileConn = (FileConnection) Connector.open (iFileName, Connector.READ_WRITE);
    If (fileConn! = null)
    {
    If (! fileConn.Exists ())
    fileConn.create ();
                   
    OutputStream os = fileConn.openOutputStream (fileConn.fileSize ());
    DataOutputStream back = new DataOutputStream (os);
    dos.writeChars (strTxt);
    back. Close();
    fileConn.close ();
    }
    }
    catch (Exception ex)
    {
    }
    }

    The function above very well written text to file. But when the txt contains \r\n which is not reflected in the line break in the file. He appears just as \r\n in the file.

    What changes I need to make sure that the line break is refrlected correctly in the file. I need to convert any other sequence of bytes using a Unicode conversion, \r\n

    try to use

    dos.writeUTF

  • How to increase the size of the file

    My application creates .amr files of 0 KB after completing the recording of the voice. How can I increase the size of the file.

    I think I am, but I write my code if you could help me.

    • This is in fact the problem is that it is not written in my .amr file if it is their creation

    whenever I call someone.

    • Furthermore it is also telling me that 'myappname' trying to record media.

    So confirmation registration takes place

    However why write records into mu .amr files intrigues me

    Thanks in advance

    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.OutputStream;
    
    import javax.microedition.io.Connector;
    import javax.microedition.io.file.FileConnection;
    import javax.microedition.media.Manager;
    import javax.microedition.media.Player;
    import javax.microedition.media.control.RecordControl;
    
    import net.rim.blackberry.api.phone.Phone;
    import net.rim.blackberry.api.phone.PhoneCall;
    import net.rim.blackberry.api.phone.PhoneListener;
    import net.rim.blackberry.api.phone.phonegui.PhoneScreen;
    import net.rim.blackberry.api.phone.phonegui.ScreenModel;
    import net.rim.device.api.i18n.Locale;
    import net.rim.device.api.ui.component.Menu;
    import net.rim.device.api.ui.container.MainScreen;
    
    /**
     * A class extending the MainScreen class, which provides default standard
     * behavior for BlackBerry GUI applications.
     */
    public final class RecordScreen extends MainScreen
    {
        Player player;
        RecordControl recorder;
        private ByteArrayOutputStream output;
        byte[] data;
        boolean yes = false;
        int st;
        /**
         * Creates a new RecordScreen object
         */
        public RecordScreen()
        {
            Phone.addPhoneListener(new PhoneListener() {
    
                public void conferenceCallDisconnected(int callId) {
                    // TODO Auto-generated method stub
    
                }
    
                public void callWaiting(int callid) {
                    // TODO Auto-generated method stub
    
                }
    
                public void callResumed(int callId) {
                    // TODO Auto-generated method stub
    
                }
    
                public void callRemoved(int callId) {
                    // TODO Auto-generated method stub
    
                }
    
                public void callInitiated(int callid) {
                    PhoneCall phoneCall = Phone.getCall(callid);
                    if (phoneCall != null)
                       /* st = Dialog.ask(Dialog.D_YES_NO,
                                "Are you sure to record this call?");
                        if (st == Dialog.YES) */
                            yes = true;
                      /*  else
                            yes = false; */
                        // TODO Auto-generated method stub
    
                }
    
                public void callIncoming(int callId) {
                    // TODO Auto-generated method stub
    
                    // TODO Auto-generated method stub
                   // Dialog.ask(Dialog.D_YES_NO, "Are you sure to record this call?");
    
                    PhoneCall phoneCall = Phone.getCall(callId);
                    if (phoneCall != null)
                        yes=true;
    
                    // TODO Auto-generated method stub
              /*      if (yes) {
                        try {
                            recorder.commit();
    
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            System.out.println("====Exception: "+e.getMessage());
                        }
                        player.close();
                        data = output.toByteArray();
                        saveRecordedFile(data);
                    }  */
    
                }
    
                public void callHeld(int callId) {
                    // TODO Auto-generated method stub
    
                }
    
                public void callFailed(int callId, int reason) {
                    // TODO Auto-generated method stub
    
                }
    
                public void callEndedByUser(int callId) {
                    // TODO Auto-generated method stub
    
                }
    
                public void callDisconnected(int callId) {
                    // TODO Auto-generated method stub
    
                    if (yes)
                    {
                        try {
                            recorder.commit();
                            data = output.toByteArray();
                            saveRecordedFile(data);
                            player.close();
                            }
                        catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        finally
                        {
    
                             data = output.toByteArray();
                             saveRecordedFile(data);
                             player.close();
                        }
                      //  player.close();
                       // data = output.toByteArray();
                        //saveRecordedFile(data);
    
                        /** _rcontrol.commit();
                       _data = _output.toByteArray();
    
                       saveRecordedFile(_data);
    
                       _output.close();
                       _player.close();**/
                    } 
    
                }
    
                public void callDirectConnectDisconnected(int callId) {
                    // TODO Auto-generated method stub
    
                }
    
                public void callDirectConnectConnected(int callId) {
                    // TODO Auto-generated method stub
    
                }
    
                public void callConnected(int callId) {
                    // TODO Auto-generated method s
                    //@@ScreenModel scr=new ScreenModel(callId);
    
                    //set language to english
                    //@@Locale.setDefault(Locale.get(Locale.LOCALE_en));
                    //get Menu
                    //@@Menu menu=scr.getPhoneScreen(PhoneScreen.PORTRAIT, PhoneScreen.ACTIVECALL).getMenu(0);
                    /*System.out.println("Menu of BB Dialler - Begin");
                    for (int i = 0, cnt = menu.getSize(); i < cnt; i++)
                        System.out.println("Menu of BB Dialler - "
                            +menu.getItem(i).toString());
                    System.out.println("Menu of BB Dialler - End");     */
                    /**for (int i = 0, cnt = menu.getSize(); i < cnt; i++)
                        if(menu.getItem(i).toString().equalsIgnoreCase("Activate Speakerphone"))
                            menu.getItem(i).run();
                    **/     
    
                    PhoneCall phoneCall = Phone.getCall(callId);
                    if (phoneCall != null) {
                        if (yes)
                            initPlay();
                    }
    
                    if (yes) {
                        try {
                            recorder.commit();
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                           // System.out.println("====Exception: "+e.getMessage());
                            e.printStackTrace();
                        }
                        data = output.toByteArray();
                        try {
                            output.close();
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        //player.close();
                        saveRecordedFile(data);
                        player.close();
                    }
                }
    
                public void callConferenceCallEstablished(int callId) {
                    // TODO Auto-generated method stub
    
                }
    
                public void callAnswered(int callId) {
                    // TODO Auto-generated method stub
    
                    // yes = true;
    
                    // TODO Auto-generated method stub
    
                }
    
                public void callAdded(int callId) {
                    // TODO Auto-generated method stub
    
                }
            });
            // Set the displayed title of the screen
            setTitle("");
        }
    
        private void initPlay() {
            // TODO Auto-generated method stub
            try {
                player = Manager.createPlayer("capture://audio?encoding=amr");
                player.realize();
                recorder = (RecordControl) player.getControl("RecordControl");
                output = new ByteArrayOutputStream();
                recorder.setRecordStream(output);
                recorder.startRecord();
                player.start();
            } catch (Exception e) {
                // TODO: handle exception
                //Dialog.alert(e.getMessage() + "");
                e.printStackTrace();
            }
        }
    
        public boolean saveRecordedFile(byte[] data) {
            try {
    
                String filePath1 = System.getProperty("fileconn.dir.music");
    
                //WRiting into a file
                //String filePath1= "file:///store/home/user/";
    
                String fileName = "Call Recorder(";
                boolean existed = true;
                for (int i = 0; i < Integer.MAX_VALUE; i++) {
                    try {
    
                        FileConnection fc = (FileConnection) Connector
                                .open(filePath1 + fileName + i + ").amr");
    
                        if (!fc.exists()) {
                            existed = false;
                        }
                        fc.close();
                    } catch (IOException e) {
                        //Dialog.alert("Unable to save");
                        e.printStackTrace();
                        return existed;
                    }
                    if (!existed) {
                        fileName += i + ").amr";
                        filePath1 += fileName;
                        break;
                    }
                }//end for
                System.out.println(filePath1);
                // output---file:///store/home/user/pictures/Photo Editor(10).bmp
                System.out.println("");
    
                FileConnection fconn = (FileConnection) Connector.open(filePath1, javax.microedition.io.Connector.READ_WRITE);
                if (fconn.exists())
                    fconn.delete();
    
                fconn.create();
                fconn.setHidden(false);
    
                OutputStream outputStream = fconn.openOutputStream();
                outputStream.write(data);
                outputStream.close();
                fconn.close();
                return true;
            } catch (Exception e) {
                 //System.out.println("====Exception: "+e.getMessage());
                // Dialog.alert("====Exception: "+e.getMessage());
                e.printStackTrace();
            }
            return false;
        }
    
    }
    
  • Open the file server .txt and analysis

    I'm trying to open a .txt on my server and analyze the content, the content is a version number and a link.

    I have something like this

    ContentConnection updateConnection = null;
    
    try {
                updateConnection = (ContentConnection)             Connector.open(updateUrl);
    
              .....
    
             ......
    
       } catch (ConnectionNotFoundException e){
                e.printStackTrace();
            } catch (IOException e){
                e.printStackTrace();
            } catch  (IllegalArgumentException e){
                e.printStackTrace();
            }
    

    I'm capturing the IOException exception. Is it possible to open a txt file and analyzed. I can change the format of the file to something else if necessary. I thought that keeping it as a txt should be ok because I have to analyze only 2 pieces of information about him.

    Thank you.

    You can use

    http://www.BlackBerry.com/developers/docs/6.0.0api/NET/rim/device/API/IO/IOUtilities.html#streamToBy...

    to retrieve the file.

    create a string from the byte array and analyze its contents.

Maybe you are looking for

  • Add a bigger hard drive of my iMac?

    I have an iMac 2010 which is ultimately to reach the original 1 TB drive capacity.  I would have maxed out a long time ago, but I do most of my storage on a set of external hard drives. Are there limits to what I can put in this computer?  I would go

  • Drivers for HP ProBook 4530 s Win 7 Home Premium 64-bit

    Recently, I reformatted my laptop Windows 7 Home Premium 32 bit to 64 bit. Now, when I install the drivers on my laptop, I get the yellow! I don't know what I should install. My USB drive does not work and I can not WiFi. I installed the driver from

  • Macro mode variable watch

    Hi all I'm sure than that used to work in 2010. If I have a macro in a formula, it will not assess in the Watch window. For example, according to iso646 can I have "has and b ' in my prog, which compiles well (#define and &).»» But by selecting with

  • Talking to me like a kintergartener games does not open

    My games will not open in the i-phone. I did something on my computer (Sync?) b4 he started to do this. Phone had problems connecting.

  • Camera NEX - 3N for Mac software

    Hello Only, I opened my camera NEX - 3N and trying to save it and download the software for my Mac and discovered that Sony software (memories of playing) does not come in a version of Mac OS. No matter what ways around it or simply not there to get