Not able to read a text file or binary

I am reading in a file text or binary, as shown in the Blackberry "how - adds an application of plain text or binary files"

http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800620/How_To _...

I use Eclipse 3.4.2 I implemented a project of Blackberry with the following structure:

Test1 (project name)

-src (folder)

|   + com.name.xxx

|   + com.name.yyy

|            Test1.Java

+ NET_RIM_BLACKBERRY

|

-test

I'm reading in the test file is at the level of the main project folder.  For example, the Test1.jdp file is located in the folder of the main project and the test file (text file or binary).  I am trying to access the file using the line of code below:

Class classs = Class.forName(this.getClass().getName());

InputStream is = classs.getResourceAsStream("/test");

The getResourceAsStream indicates that the file will be in the same location as the location of the Test1.jdp file if the bar oblique is in front of the name of the file, or that it will look in the source for the main class file.  When I have the slash I get error

CAFETERIA: could not find the test file

I tried several different attempt to get to the CAFETERIA to find the file, but I'm running out of ideas and I would appreciate someone else's ideas on what to try.

Thank you

Thank you klyubin and stef

I found a solution that works for me with Eclipse plug-ins, JDE.

First, the example of Blackberry in the how-to (see original thread number) with test as file is named simply 'test '.  This does not work for me at all in Eclipse.  I gave up to place the file in the folder of the project Eclipse (main folder) and placed in the src folder, which of course gives a compile error because is not a Java file, and of course when using file name in my java code I changed the code correctly as in the first line that follows :


// this will look in the source folder of the class // that myClass refers tois = myClass.getResourceAsStream("test.txt");

// this is supposed to refer to a file called 'test' // in the source folder of the class that myClass refers to // but apparently for Eclipse it must have a .txt extension// as in the above exampleis = myClass.getResourceAsStream("test");

// this is supposed to refer to a file called 'test' // in the main project folder but not apparenlty for Eclipseis = myClass.getResourceAsStream("/test");

// this is supposed to refer to a file called 'test.txt' // in the main project folder but not apparenlty for Eclipseis = myClass.getResourceAsStream("/test.txt");             } 

Note: I was also getting the error message when I place the file named "test" in the src below directory.  I managed to get rid of this error message by configuring the path building (similar to deleting the file of the JDP file including klyubin suggested above for Blackberry JDE ordinary rather than the plugin Eclipse) to remove the file 'test' for compiling so I would not get the compile error.

However, this was not my main problem - if you name the file test.txt and place it in the src directory you do not get this error I believe.

Errors during construction

Errors running builder "Blackberry resources Builder" on the project...

Could not compile files

java.io.FileNotFoundException: C:\path to the file I had added in the directory\.rrh of the source (or some truncation of the file name .rrh - for example te.rrh)

Finally, I have checked the jar (as klyubin suggested) file that is created when I place the file 'test' or 'test.txt' in my Eclipse project main folder.  The jar file did not contain the name file and so when I run in the Simulator, the file is not found.  Even when I put the file in the jar (main directory) myself the Simulator still could not find the file.   When I placed the test.txt file in my directory src the jar resulting file contains the file named and the Simulator can find the file ok.

So, it seems to me that for the plug-in Eclipse JDE contextual explanation of the method getResourceAsStream does not apply as described at this time.

getResourceAsStream

public InputStream getResourceAsStream(String name)

Looking for a resource with a given name. This method returns null if no resource with this name is found. The rules looking for resources associated with a given class are specific profile. RIM implementation notes: this method searches the resource from the directory in which the current JDP project file is located. By default, it is assumed that this JDP file resides in the parent directory of the package of the current project space. Thus, the package space tree (for example, com/rim/PackageName) is added to name so that the search begins from this space package, that is, in the source directory of the current project. However, if the current JDP project file does not lie in its presumed location, the behavior above prevent the resource located. In this case, the user must add a slash (/) in the name of the resource before calling getResourceAsStream. This treats the name as an absolute path, which is compared to a tree whose root is the location of the JDP file. Parameters: name - name of the desired resource Returns: a java.io.InputStream object. Since: JDK1.1

If Alain klyubin (or someone else) can enlighten us more on why the file should be named *.txt to find the file in the source directory, which can be useful to me and others in the future.  My real goal is to read in an image file named *.jpeg.  We'll see how it goes.

And thank you klyubin for the suggested code change which I had also found in another thread...

// this was more than what was necessary//Class myClass = Class.forName(this.getClass().getName());

// this is simpler  Class myClass = this.getClass();

And so many other Eclipse users who try to follow the Blackberry How To - add a text or a binary file in an application, do not forget to consult the file name in your code java as in the examples that I gave above.

Tags: BlackBerry Developers

Similar Questions

  • Not able to read the text file several times - Bug?

    I open the Refnum to a text file by starting my software and I'll keep the file open until the software works. I read a text file when an event occurs. The problem that I'm facing here is when I read that the file 1st time Lily can't read the text of the file but when I read it to get even empty string only. Could someone help me understand why this happens.

    A race condition?  What's with the two readings at the same time?  Keep the opened file is not a problem, but remember that there is a file pointer.  If you read empty strings, it's probably because you're at the end of the file.  Use Set leader VI to set Position is for the beginning of the file.

  • Not able to reverse the text file in ODI

    Hi guru,.

    I tried to load the data from Oracle database to text file. But I am facing problem during file reverse text.

    The columns in the text file are not reversed in the ODI data store. I get no error.

    Are there specific measures that I'm missing here? Any ideas / docs / links would be appreciated.


    As a solution, I added column manully right now and I can go futher. But I would be happy if reverse ODI will do it for me.

    Kind regards

    Manmohan Sharma

    Hi Matt,

    A thought,

    Make sure your data store is NOT LOCKED (UNLOCK) in reverse.

    Thank you
    Guru

  • Not able to read the wsdl file while initiating the process

    I was able to deploy BPEL processes in the Production environment without any error. At the moment that I clicked on "Start" in Console of BPEL, he threw under the exception:


    I tried to access http://servername:9000/orabpel/default/XX_BPEL_INTF_MON/1.0/_XX_BPEL_INTF_MON.wsdl directly and I was able to access the wsdl page.
    I looked in my code given namespaces (http://schemas.xmlsoap.org/wsdl/ "namespace or the namespace" http://www.w3.org/2004/08/wsdl"), but he was not present.
    I did redeploying several times without a bit of luck.

    There are other BPEL process installed on the server. Here are the differences:
    1. I am start my process BPEL using the BPEL Console, others do so with some clients in java.
    2 exception watch URL wsdl to be http://servername:9000/orabpel/default/XX_BPEL_INTF_MON/1.0/_XX_BPEL_INTF_MON.wsdl containing "_". ("_XX_BPEL_INTF_MON.wsdl") Although it is without "_" (XX_BPEL_INTF_MON.wsdl) under the section of the WSDL location. However, I can access both using the browser.

    While everything works well in the DEV environment.

    Rescue me.


    Complete cycle of Oracle BPEL Process Manager
    An unexpected error occurred during the execution of your request. This is probably related to a defect in the product, Oracle BPEL Process Manager. We apologize you can post the error on the OTN forum and we will respond as soon as possible.

    Attachments:

    Update information:
    Oracle BPEL Server version 10.1.2.0.2 Build: 2196 construction time: kill Jan 10 12:31:53 UTC 2006 Build type: release the tag Source: BPEL_10.1.2.0.2_GENERIC_060110.1200


    Exception message:
    [javax.servlet.ServletException] α wsdl reading failure. Cannot read the wsdl to 'http://servername:9000/orabpel/default/XX_BPEL_INTF_MON/1.0/_XX_BPEL_INTF_MON.wsdl', because ' WSDLException: faultCode = INVALID_WSDL: document: http://servername:9000/orabpel/default/XX_BPEL_INTF_MON/1.0/_XX_BPEL_INTF_MON.wsdl is not a wsdl file or does not have an element root "definitions" namespace "http://schemas.xmlsoap.org/wsdl/" or the "http://www.w3.org/2004/08/wsdl" namespace. " Make sure that wsdl is valid. You must start the server of OraBPEL, or ensure that the related bpel process is deployed correctly.


    Trace of the exception:
    javax.servlet.ServletException: cannot read the wsdl. Cannot read the wsdl to 'http://servername:9000/orabpel/default/XX_BPEL_INTF_MON/1.0/_XX_BPEL_INTF_MON.wsdl', because ' WSDLException: faultCode = INVALID_WSDL: document: http://servername:9000/orabpel/default/XX_BPEL_INTF_MON/1.0/_XX_BPEL_INTF_MON.wsdl is not a wsdl file or does not have an element root "definitions" namespace "http://schemas.xmlsoap.org/wsdl/" or the "http://www.w3.org/2004/08/wsdl" namespace. " Make sure that wsdl is valid. You must start the server of OraBPEL, or ensure that the related bpel process is deployed correctly. at com.evermind.server.http.EvermindPageContext.handlePageThrowable(EvermindPageContext.java:595) at com.evermind.server.http.EvermindPageContext.handlePageException(EvermindPageContext.java:537) at _ngDoInitiate._jspService(_ngDoInitiate.java:438) at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:350) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824) at com.evermind.server.http.ServletRequestDispatcher.include(ServletRequestDispatcher.java:121) at com.evermind.server.http.EvermindPageContext.include(EvermindPageContext.java:267) at _displayProcess._jspService(_displayProcess.java:792) at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:350) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330) at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:222) at com.collaxa.cube.fe.DomainFilter.doFilter) DomainFilter.java:152) to com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:663) to com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330) to com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830) to com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:224) to com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:133) to com.evermind.util.ReleasableResourcePooledExecutor$ (ReleasableResourcePooledExecutor.java:192) MyWorker.run at java.lang.Thread.run(Thread.java:534)

    Thank you
    Nawnit

    Published by: user649251 on December 9, 2008 08:53

    Think something is stuck in the cache. I would cancel the deployment of the process of the console, then I bounce off the application server, and then redeploy.

    If this does not work, perform the same steps but after you cancel the deployment of remove the code from the file server bpel deployment. I forgot when this is in the 10.1.2.0.2 version but it will be in the House of bpel. If you do an ls - a it's a file hidden under unix. The file name will have lost garbage with the process name in the name. This should eliminate any past existence.

    see you soon
    James

  • UTL_FILE.get_line not able to read large files...

    Dear all,

    UTL_FILE.get_line is not able to read data from file. can you suggest me to fix this problem...

    Here is my code;

    declare

    l_file_handle UTL_FILE. Type_de_fichier;

    l_input_line varchar2 (6000);

    Start

    l_file_name: = 'abc.csv ';

    l_path: = ' / u02/R12UAT/apps/apps_st/appl/XXSES/12.0.0/bin';

    l_file_handle: = UTL_FILE. FOPEN (l_path, l_file_name, 'R', 32767);

    loop

    UTL_FILE. GET_LINE (l_input_file, l_input_line);

    fnd_file.put_line (fnd_file.log, l_input_line);

    end loop;

    UTL_FILE.fclose (l_file_handle);

    end;

    After reading a few lines I have a get the error;

    ORA-06502: PL/SQL: digital or value error: character string buffer too small

    I have to read data from file with UTL_FILE. Do not use SQLLDR

    Thank you.

    Kind regards

    Ravi.

    Your call to FOPEN() function specifies a size of 32K maximum line. When you call GET_LINE() without specifying the number of characters to get, Oracle will therefore assume you want to get 32K characters. However, your stamp, L_INPUT_LINE, is defined as VARCHAR2 (6000). That is, it is much too small.

    The solution is to call GET_LINE() with the third parameter set to 6000.

    BTW, you can also set a condition of release on the loop.

  • Windows 7 / rtf problem is horrible! fix it! Why not windows 7 read the rtf files? I have a lot of these old files, and I can't open an any of them.

    I have on dvd rtf files.  Windows 7 will not open not except in wordpad, where they are filed with the illegible ^ & * % $ who make up the formatting instructions.  What a ridiculous problem and should be a response provided by microsoft.

    Hi Rachelde,

    Please go to the Microsoft Community Forums.
    From the description of the question, we understand that WordPad is not able to read DVD rtf files.
     
    If you could answer a few questions that would help us resolve this problem:
    1. have you tried to access the rtf from another computer files?
    2. is the specific question on DVD or with all rtf files rtf files?
    3. are you able to read files after copying DVD to computer?
     
    Respond with answers to the questions above so that we can better help you.
  • Not able to read files audio wma

    I myself had this new cool device and everything is working fine beside it is not able to read files audio wma.
    It works without any problem on my Samsung android phone, but on my Slate7 it says format not supported in specifications indicates that it is supported.
    I installed the same player that I use on my Samsung android phone, any suggestions I should do to fix this?

    To my knowledge 4.1 Android doesn't have the necessary codec to play default WMA files. Please see the compatible audio formats listed by Android developers:

    http://developer.Android.com/Guide/Appendix/media-formats.html

    However, for me MXPlayer/VLC works to play WMA files. You can try this one, and there is no harm to try. Two of them are available on PlayStore. You can uninstall them if you don't like them or if they do not meet your needs.

  • Stor.e TV 1.5 TB - not able to read .avi files

    I transferred .avi files from my computer on Stor.e tv and for some reason the icon on the left is a question mark instead of the usual.

    Not only that I am not able to read .avi files.
    The strangest thing happened only in some of the files (4) I was transferred.

    Can someone please help?
    Thank you.

    Hello

    Have you tried to repeat this procedure?
    Delete the files copied to the HARD drive and copy the files once more.

  • PS is not able to read the files from my Olympus OM - D E - M1 camera

    I have an old Version of Photoshop, CS3, Version 10.0. Now, I bought a new camera, an Olympus OM - D E - M1, and the PS is not able to read the files. Can I download a few extend camera raw?

    Per-Erik Pedersen

    Hi Peders,

    Thanks for posting on the Adobe forums.

    This camera is supported by Camera Raw 8.2, which is available in Photoshop CS 6. Please check the following KB Articles:

    Camera Raw plugin | Supported devices

    Applications of camera Raw compatible Adobe

    Kind regards

    Sandeep

  • testimonial widget that reads the text file

    Is there someone who makes a testimonial widget that can read a text file? I am considering this is a block for customer testimonials that can read a file of say 50 different clients we wil cut and paste from various places, so that there is always a fresh review illustrated.

    Themes of Muse has some text widgets: one as a ticker-tape driveand displays a (small) number of citations. But none will allow you to modify a file of text outside the Muse of let's say 50 paragraphs and read on the page, one by one, in order.

    There are a lot of scripts to do exactly what you want, like this: alternating Message text box . JavaScriptSource, and many others, just Google: "alternating rotation script of text message". But are you able to manage scripts and HTML codes in Muse ? Maybe some useful script Wizard can cook a place for you or modify an existing one, provide you a text template file and help hair and be implemented in Muse page.

    Don't let them not to edit your output !

    Ask them to help you with a method to ensure within the Muse:

    1. adds a style and script in the header of page (see Page Properties)

    2 Insert the HTML code on the page (under the object menu)

    3 attach the text file on the site (hyperlink, link to the file)

    So, you can change the text file and download all changes with Muse.

    Hope this helps?

  • USB for my iPhone, so it can read a text file

    Hi, I would like to be able to connect a standard USB to my iPhone, so it can read a text file from USB, any suggestions on cable/apps? Thank you, Tony

    Hello. In fact, you can use any USB adapter to connect your iPhone to the computer and transfer text files. Apple recommends the adapter like this http://www.apple.com/shop/product/MD820AM/A/lightning-to-micro-usb-adapter

  • Hi there, I need to be able to read the raw files on an Olympus Stylus 1 via CS5 and Lightroom 4.  I downloaded Raw plugin v 6.7.1 file but still cannot read the files.

    Hi there, I need to be able to read the raw files on an Olympus Stylus 1 via CS5 and Lightroom 4.  I downloaded Raw plugin v 6.7.1 file but still cannot read the files?

    Read this http://helpx.adobe.com/creative-suite/kb/camera-raw-plug-supported-cameras.html table

    The Olympus Stylus 1 was first supported Camera 8.3 crude which is compatible with the CS6 and CC.

    It is not compatible with CS5 or more and never will be.

    If you do not upgrade to CS6 or CC, then you can dwonload the free Adobe DNG converter, convert all Stylus 1 Raw files to DNG, and then edit the DNG in CS5.

    Camera raw, DNG | Adobe Photoshop CC

  • Why I'm not able to open a pdf file whenever I do it is getting me to purchase a program screen?

    Why am I not able to open a pdf file now? Whenever I get an email with an attached PDF file and I download on my computer when I go to open it instead to open the document, it takes me to a screen to buy your product?

    It seems that you have inadvertently installed the trial version of Adobe Acrobat. You must uninstall that and install Adobe Reader (free).

  • A form of Oracle, I want to read a text file.

    A form of Oracle, I want to read a text file. In shape on a press of button I have:

    declare
    in_file Text_IO. Type_de_fichier;
    linebuf VARCHAR2 (1800);
    filename VARCHAR2 (30);
    BEGIN
    filename: = GET_FILE_NAME ('U:\ora_devl\pps\work\a.txt', File_Filter = > ' text (*.txt) | * .txt |');
    in_file: = Text_IO. Fopen (filename, "r");
    LOOP
    Text_IO. Get_Line (in_file, linebuf);
    -: text_item5: =: text_item5 | linebuf | Chr (10);
    Text_IO. New_Line;
    END LOOP;
    EXCEPTION
    WHEN no_data_found THEN
    Text_IO. Put_line ("Closing the file...");
    Text_IO. Fclose (in_file);
    END;

    He gets an ORA-302000. I suspect that the problem starts with the GET_FILE_NAME because when I comment, but treats it continuously without end.

    Forms [32 bit] Version 11.1.1.3.0 (Production)
    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    What can you tell me? Thank you

    GET_FILE_NAME will try to open a 'Open file' dialog box on the server, which obviously cannot happen. If you want to use this type of behavior, you must use the function CLIENT_GET_FILE_NAME and WebUtil. Example:

         filename := CLIENT_GET_FILE_NAME('C:\', File_Filter=> 'Text Files (*.txt)|*.txt|All Files (*.*)|*.*|', dialog_type=> OPEN_FILE);
    

    See the Help Builder Online for more details. You can also view the demo which is available here:

    http://www.Oracle.com/technetwork/developer-tools/forms/downloads/index.html

    More information here:

    http://www.Oracle.com/technetwork/developer-tools/forms/webutil-090641.html

    In addition, it seems that you try to use a mapped drive ('U'). Although this can be made to work, it is not recommended and in some cases is not supported. If you need access to remote files, you must use another mechanism to put the file on the local computer before handling.

  • How to read a text file with line breaks

    Hello

    I'm reading a text file in a textFrame.  We read in, but does not include line breaks is just a big long line of text.  I use the following code to read the file.  I tried to insert a \n character after each readln() but that has not helped.  I also tried to create a variable that the readln() was crammed in before setting the textFrame.contents variable, but which does not work either. I'm puzzled. Any help would be appreciated, thanks.

    While (! notesDoc.eof) {}

    noteTextRef.contents += notesDoc.readln ();
    }

    Doug

    Just use fileObect.read () instead of fileObect.readln () / / read online also try to use instead of \n \r

Maybe you are looking for

  • Junk e-mail address goes directly

    Suddenly - and I mean all of a sudden without asking confirmation - mail addressed to a particular address goes directly to my junk e-mail folder.  And what is particularly strange is that emails are not marked as spam (as in, when I click on an emai

  • Kernel panic error

    Hi all I have recently several kernel panics on my Mac Pro. His repeting so many times and I don't know how to do. It's the file error, that the system generates. I'll be more than happy if someone can help me solve the problem. Interval since the la

  • X 220, Wirelss AC update possible?

    I always use my X 220 and I like it, but the WiFi leaves something to be desired... I think that the map Intel 6250 is crapping because it stops passing data (do not remove) at random times. It's something I've struggled with 6 + months now, it has h

  • Bad driver of the Internet

    I have HP 630 Notebook A1E27EA #BED, OS: Windows 7 Ultimate 32 bit. I have a little problem. I installed driver Atheros wifi and the pilot did not work right. I got the wifi pilot before I have to reinstall the OS and I don't remember name. This work

  • Boot SSD on charges windows configuration install on the Aspire S3 - 951

    I am trying to install Windows on an Aspire 8.1 s3-951. The computer has two drives, a 20 GB SSD for the startup, then a larger storage drive. Before I removed Windows 7, Windows displays only a large disk. I installed Windows 8.1 on the SSD, but I c