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.

Tags: BlackBerry Developers

Similar Questions

  • How to read and write a text file to the folder of the user preferences?

    I'm trying to code for the user to record the plug-in, the first time that the user opens Acrobat after you have installed the plug-in. I want to write a file of registration of preference of the user folder access later to check that they are already registered.

    Is there an easy way to do this? I wrote the code to access the preference of the user folder to search for the file, but I have not been able to code for the write file. All I've found is how to write a PDF file.

    Any suggestions?

    Gregory

    ASFileRead/ASFileWrite

  • 5 Lightroom can't read and import the raw file

    I can't import my RAW files from my Nikon D750. When I try to import my SD card, I am able to see the preview, but when I try to import, I get a window that reads "the following files were imported not because they could not be read. I haven't changed anything on my camera on the LR5 parameters settings and this happened just today. I am able to transfer the files on my desk at the moment, but I can't yet import from there. I also tried reformatting the card and even tried another card so I don't think that the problem is the card or the device itself. I also do not seem to see updates that I need. Does anyone have any suggestions?

    As noted of Claes, it is almost certainly a problem with your destination set wrong in the import Panel. This happens quite easily. You get the error message is almost always due to the destination without folder do not write access. Really check your destination. This should NOT be the root of your startup for example disk level and for some reason any sometimes default Lightroom at this place and then refuses to import because the OS refuses to let you write here.

  • Satellite A300-146 - CD/DVD read and write the question

    I have Toshiba Satellite A300-146, model No.: PSAJ0E, 1 GB of RAM, Intel Dual core 1.87 processor, chipset Mobile Intel (r) 965 family
    I use the windows7 RC version.

    My DVD burner does not work correctly.

    (* 1) not read 700 mb CD and don't read do not more DVDs.*
    A few months ago he read sony DVD, read all CD and dint read some local DVD. Now, it is not read sony DVD and and all the CD that I used. But reads the local DVD...

    (* 2) a few times it can write DVD but most of the time this is not not writing DVD Nero 7 display of 100%, but the DVD is not written anything.*

    I use Vista drivers for my Window 7 operating system...

    3. should I install windows 7 drivers... ?

    4. are there specific drivers for DVD player. ?

    Experts or those who have recovered from the same problem. Please help me.

    Thanks in advance.

    Hello

    Maybe your CD/DVD drive becomes faulty... What do you think?

    But before you think to a new disk, you must remove the server - and lowerfilters in the registry. You can follow the workaround from Microsoft:
    http://support.Microsoft.com/kb/314060

    Also, make sure that the CD/DVD drive lens is clean. You can use a microfibre cloth to clean. This rag doesn't scratch the lens.
    Check this box!

    Finally and above all, there is no special driver for CD/DVD drive. It s a part of t Windows and can be updated.

  • How to read and display the .ai file in CS4 SDK?

    Hi all

    I drew an own and saved the socument as file traingle.ai.

    Now, I want to read/open the traingle.ai file in the plugin.

    [Lets say, I want to read this file based on GoFilter ()]

    Is there an API to read file .ai in CS4 SDK? and display as well?

    If you mean autonomous (outside Illustrator) the answer is no. The SDK is reserved for the plugins loaded into Illustrator. If you want to open a file from Illustrator that is perfectly doable if. I think that AIDocumentList:: open() that will handle.

  • Need to re - register a completed form on in Acrobat Reader and keep the same file name.

    I did collect a form developed for our client in. They need to access and save it several times without making several versions.

    Now that they can open, fill out some fields and "save under" a different file name. They must then go back and edit or add additional information to train at a later date.

    He won't let not the re - save the file with the same file name, only "save under". It is not very practical because they will end up with many versions of the same shape and all earlier versions would be obsolete and useless for them.

    You must disable the preview in Windows Explorer or close Windows Explorer.

  • Read and write data to the content repository.

    Hi all
    We use the content repository to store a document and images on the web server in the Center.
    So we have created/setup a repository of content on the web center.
    Please proivde me some might document page to get an idea of how I can read and write the date
    content repository.
    You are most welocme to provide some idea /suggestion.
    Thank you
    Arun.

    You are using webcenter spaces or you create a custom application webcenter?

    When you create a custom application webcenter, you can make use of the workflow Documents. Jdeveloper resources catalog, you will find a few flows of Documents job that will allow you to add some components to manage documents in a folder structure.
    You must first create a connection to your content from your application server. This can be done in the Application resources, right-click on the connection and in the context menu, select "content repository". Them you must filll in connection to your content server details. Make sure you have selected "Set as primary connection for document service" because otherwise the document taskflows you deposit on your page will not find a connection.

    Once you have added the connection, you will also find a datacontrol to the content repository. In this way, you can use the datacontrol place the taskflow and you can create several custom tables.
    I'm not sure but I think the datacontrol also include surgery to create the document but I'm not sure...

    And if not enough, you can always do use the webservices provided by content server. In Jdeveloper you can easily create a datacontrol from Web services by providing the wsdl file. UCM provides for services so that you can import the wsdl into your application and you can easily create your own forms checkin, tables...

    Here is some information on how to integrate services document:
    http://sqltech.CL/doc/oas11gR1/WebCenter.1111/e10148/jpsdg_doc_lib.htm

    and here are some others:
    http://sqltech.CL/doc/oas11gR1/WebCenter.1111/e10148/jpsdg_content.htm#BABCCFJH
    http://sqltech.CL/doc/oas11gR1/WebCenter.1111/e10149/documents.htm#WCSUG2635
    http://sqltech.CL/doc/oas11gR1/WebCenter.1111/e12405/wcadm_documents.htm#WCADM205

    Published by: Yannick Ongena on Oct 8, 2010 08:23

  • read and write performance vm information top 10

    Hello

    I wonder if it is possible to have some information about reading and write the totals of the IOPS / s and latency? The only one i have now in Explorer 'storage '. "VM performance top 10" is average information and tip of the Ops / s and latencies. I need information of reading and writing of the virtual machines instead of the totals.

    Thanks in advance.

    GER.

    EDIT: I noticed that the discussion is started in the wrong forum. I use VoP server explore FREE

    Hello

    Unfortunately, the free tool there is no distinction between read and write IOPS / s or latency.  They are grouped in a single total.

    -Brad

  • Brander DVW/RW can read and write DVD double layer dvd

    Hello

    I would like to know if brander DVD/RW can also read and write the DVD DL(dual layer) dvd.

    or I have to buy for that special brander!

    Johan

    What is a "brander DVD/RW?   Support double layer DVD depends on the material.   Try to identify the make and model of the car since the Device Manager and find its specifications.

  • Reading an XML file and write the content in another file xml in java

    Hello

    I'm new to xml parsing. My requirement is that I get a message (xml) using ibm MQ in the ByteArrayInputStream format. I read this xml message and write to another file.

    To do this, I create a CEP.

    First of all, I used simple reading and writing concept, but the output is "java.io.FileInputStream@3e25a5".
    Example of xml file
    -< customer >
    < > 1234 ClientId < / ClientId >
    STechnology < ClientName > < / ClientName >
    < DTU_ID > 567 < / DTU_ID >
    < ClientStatus > ACTIVE < / ClientStatus >
    -< LEAccount >
    < Customer > 678989 < / customer >
    < > 56743 LEId < / LEId >
    -< account >
    < AccountNumber > 9876543678 < / account number >
    < / account >
    < / LEAccount >
    -< Service >
    Y2Y < Cindicator > < / Cindicator >
    < PrefCode > 980 < / PrefCode >
    < BSCode > 876 < / BSCode >
    < MandatoryContent > MSP < / MandatoryContent >
    < / service >
    < / customer >

    Code:


    import java.io.ByteArrayInputStream;
    import java.io.FileInputStream;
    to import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;

    public class ByteArrayInputStreamToXml {}

    Public Shared Sub main (String [] GIS) throws IOException {}

    InputStream inputStream = new FileInputStream("C:\\soft\\test2\\sample1.xml");
    currentXMLBytes Byte = inputStream.toString () .getBytes ();
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream (currentXMLBytes);

    OutputStream out = new FileOutputStream("C:\\soft\\test\\data.xml");
    int read = 0;
    ubyte bytes [] = new byte [1024];

    While ((read = byteArrayInputStream.read (bytes))! = - 1) {}
    out. Write (bytes, 0, read);
    out. Write ("\n");
    }

    inputStream.close ();
    out. Flush();
    out. Close();

    System.out.println ("new file created!");

    }

    }

    Please suggest me how can I use DOM/SAX parser, I see several code on the net to read the xml file using SAX/DOM parser, but write an xml file after reading using ByteArrayInputStream I don't get. Assistance through some link examples will also be useful for me.

    Thank you
    Sumit

    Published by: user8687839 on April 30, 2012 02:37

    Published by: user8687839 on April 30, 2012 02:43

    user8687839 wrote:
    But the file is coming thanks to a queue and byte format. Must read the byte, and write to a file. So, how I tried to read the byte using the code above. Please suggest me the correct way.

    Simply write the bytes of the contents of the queue directly to a FileOutputStream. Still no need to SAX or DOM!

    Pseudo-code-

    Open a FileOutputStream .
    
    Until all the bytes of the queue have been read
        read some bytes from the queue.
        wite these bytes to the FileOutputStream.
    
    Close the FileOutputStream.
    

    Published by: sabre150 on April 30, 2012 11:30

  • How to read and write files .exe to soa using the file adapter?

    Hello

    I have a requirement, that I need to read and write files .exe to soa using the file adapter.

    Can someone help me.

    Thanks in advance,

    Divya.

    Hi Vijay,

    I tried with opaque. It works for me.

    Kind regards

    Adkins

  • How to read and write attributes using the API?

    I'm trying attributes of access (read and write) of the following:

    SequenceFile

    Sequence

    The sequence steps

    When you look at the documentation of the API, TestStand, the following functions are available:

    PropertyObject

    Properties

    Attributes (read-only)

    HasAttributes (read-only)

    Methods

    DisplayAttributesDialog

    I tried to use the SetValString and GetValString commands using the reference of the attributes, but it does not seem that the data is stored in the file.

    I can't find the following information in the TestStand API:

    1. Where the attributes are stored in a property object?

    2. How can we access through the API?

    No advice and no information is appreciated!

    You must increment the number of changes to the file after that editing the sequence editor (or UI) won't refresh or mark the file, as amended. Use sequenceFile.AsPropertyObjectFile (). IncChangeCount().

    SequenceFile attributes are stored in the SequenceFile.Data, not the object of SequenceFile object. You can change them in the Advanced tab of the properties of the file sequence dialog box.

    Hope this helps,

    -Doug

  • Using the same interface CAN read and write

    Hello.

    Can I use the same CAN interface to read and write?

    For example:

    I send you CAN frame using CAN1 to my MCU.

    IF MCU confirmed the order of receiver it immediately sends the echo return command and there different ID to send the command.

    I tried to use CAN1 output framework and then reconfigures CAN1 to frame in queue and retrieve the frame of the echo.

    But it seems that I was always missing. The 'framework of CAN' kept vi expire.

    When I used the separator on the outlet BOX in my configured MCU CAN1 for frame and CAN2 for chassis in and I managed to catch the echo framework.

    I think about 100 ms for the frame in response that will be sent after the order has been received. It takes longer for the NI PXI-8513 reconfigure? Can I still do it, or I have to use the separator?

    I wad jump to use an interface to read and write.

    Thank you

    Ok. I misread your notion of echo. I understand now. I'm sorry.  The code you posted seems reasonable.

    (1) did you notice on or off for the session?

    (2) what baud rate? You can add a parameter of baud rates for the property to be explicit node.

    (3) I don't remember the name of VI, but you can add a status of Comm Get after reading. This will give you some information about the bus - if errors were detected, etc. Which can be useful to help debug.

  • Impossible to find the field read and write VI in labview 2009

    where is the field point to read and write VI in labview 2009

    According to the version of LV, BT pallets can be sensitive to the context. Try to create a project and add a fieldpoint target to the project.  Right-click on the target of FP in your project and select new > vi.  Now FP functions should appear

  • TCP Read and Write at the same time

    Hello everyone,

    I have a question about parallelism in TCP connections.

    I know that it is possible to read and write on the same connection ID.

    So, if you ReadTCP and WriteTCP block each other, if you use the same TCP connection ID?

    Or to request more precise if I run two while loops, in parallel, with one end by calling WriteTCP and the other called ReadTCP.

    one of the delay of loops (or block) will be the other if both loops call their VI TCP at the same time right?

    The system is Windows 7 and Labview 2012.

    Kind regards

    Sebastian

    They are perfectly parallel.  Just write in one and read it from the other.  There is no conflict.

    See My TCP articles for more details.

Maybe you are looking for

  • MacBook Pro does not stop.

    My MacBook Pro will be stop or restart.

  • HP r254nu: Bluetooth problem

    Hello. I have a problem with my Bluetooth. When I turn ON start search... about 15 min aaaand can't find my phone. When I try to find my RESUME on my smartpohne - same sh * t! Is there a problem with some drivers or what? Please help me. Greetings!

  • How you hold on a second computer to your att dsl to make it work?

    Eager to add a second computer at home. Is there something special that needs to be done for this? I have an ATT DSL. Eager to add an old HP Pavilion for children...

  • update available to another help thread

    Hello can someone help me to implement the next logical step. Add a first animation to layout manager After 1 minute remove the first animated film of layout manager Add a second animation layout manager

  • Can't find the set of patches 'superset' or 'Replaced' MOS

    HelloI have an old base Oracle 11 GR 2, which want to patch 11.2.0.1-> 11.2.0.3.Through Google, I found it as patch = 10404530.But I'm unable to find through the option patches & updates to MOS.Here's wat I entered:Product: Oracle Database - Enterpri