Unable to read file using Connector.open

I have written following code to display contents of file on mobile but it is not working and displays nothing.
Please Tell me where i am wrong.
FileConnection conn;
InputStream ip;
StringBuffer str=new StringBuffer();
public void startApp() {
display = display.getDisplay(this);
form = new Form("Hello World");
display.setCurrent(form);
try {
openFile();
} catch (IOException ie) {
public void openFile() throws IOException {
try {
conn = (FileConnection)Connector.open("file:///C:/hello.txt");
ip = conn.openInputStream();
while ((ch = ip.read()) != -1) {
str.append((char) ch);
form.append(new String(str));
display.setCurrent(form);
} catch (IOException ie) {
Thanks.

Yogesh,
Please next time paste the code using *{ c o d e }*.
Don't swallow exceptions, but print StackTrace and see, what is happening.
Daniel

Similar Messages

  • Unable to read File using File Adapter

    Hi,
    I am using File adapter to read XML file.
    I able to write payload contents to file. but using same schema, path i am unable to read the file.
    receive process is not initiating.
    what could be the possible issue?
    Thanks

    Could you please give more info about the configuration, like the spring file entries? Do you see any errors in the server log? Thanks.

  • Unable to read file - opening a html file with excel

    Hi all,
    I have the next issue:   I have developed a report on HTML format, however when I export this one (to excel) I save the file with a 'xls' extension, however, (in excel 2007), when I try to open the file I get the error "Unable to read the
    file".
    can you help me with this issue?

    Hi,
    Did you create a PivotTable report in the file? As your description, the HTML format could be used correctly in Excel 2007. Did you get the other error message?
    Such as,Unable to read file.
    When you click OK,   you receive the following error message:
    Errors were   detected in '<var>filename</var>.xls', but Microsoft Excel was   able to open the file by making the repairs listed below. Save the file to make   these repairs permanent.
    PivotTable report   '<var>report_name</var>' on   '[<var>filename</var>.xls]worksheet_name' was discarded due to   integrity problems.
    Please try to use the workaround:
    Turn off AutoRecovery when you work with any workbooks.Click Excel button>Excel options>Save>Uncheck AutoRecovery
    Following this, if the issue exists, I recommend you fix the issue the following KB:
    http://support.microsoft.com/kb/943088
    http://support.microsoft.com/kb/929766
    Regards,
    George Zhao
    TechNet Community Support

  • Intermittent 'Unable to read file' error when exporting/opening .html to .xls

    Hi, hope someone can help.
    I have an issue where I export a report from the Salesform platform to Excel. The file that is being exported is in html format and the report does not include any Pivot tables.
    The 'Unable to read file' error occurs intermittently, when Excel is already open and you export/open it from Salesforce...
    Have tried using Excel in safe mode with all the add-ins disabled and still no joy. The
    Do not save encrypted paged to disk option has been un-ticked the in Internet Options -> advanced.
    The issue happens in IE and other browsers, after raising the issue with Salesforce support they advised to raise the issue with MS instead, so here I am to see if anyone can help!
    Any help would be much appreciated

    Tools>Internet Options>Advanced tab, uncheck "Do not save encrypted files to disk"
    check your GPO settings to see if you have configured this to be unchecked.
    Thx.
    Rob^_^

  • Unable to read file. may be in use missing or corrupt

    I'm trying to transfer my music from Zen Micro to pc. Some music transfered but most didn't. When I try to transfer I get that message " Unable to read file, may be in use missing or corrupted. Did the disc cleanup for zen also. Any help would be great.

    Agapyla, two possible reasons you can't see the .idlk files. One, you're looking in the wrong place, or two, your OS doesn't consider .idlk files to be "system files."
    Option 1: In InCopy or InDesign, click inside the story you're locked out of, and open the Links panel. That story will be highlighted. Right-click on the highlighted story and choose Reveal in Finder (or Reveal in Explorer if you're on Windows).  That will bring you to the folder where the InCopy story (ICML) is. It is inside that same folder where you'll find the IDLK file.  A story's IDLK file is always at the same level as its ICML file. It might be at the top or bottom of the list of files in that folder if you're viewing them as a list sorted alphabetically. So scroll through.
    Option 2: See if there's a setting in your OS to view "invisible" files, or Google for a utility.  I think "system" and "invisible" are the same, but maybe not.  Personally I use my FTP program which lets you see your local hard drive on one side of the window and the remote server on the other side. The FTP program defaults to showing *all* files on both sides. So for me it's a quickie way to see the IDLK files. The IDLK files begin with characters that force the OS to not show them, like a period or a tilde.
    Honestly, if you're seeing a slash through a pencil icon, that file is locked, so there's an IDLK file somewhere. That's the only way ID or IC will show that icon. 
    In case of emergency: In InDesign (can't do this in InCopy), select the locked story and Unlink it in the Links panel from the Links panel menu. It breaks the link to the original ICML file an turns it back into a normal InDesign text frame. Then select the frame, and export it to InCopy format again *with a different filename* than before, but saves it to the same place as the other ICML stories for that layout.
    AM

  • How to open/read file using Java in Unix?

    Hi Friends,
    Can you please help me out how to open/read file using java in unix os? I have create one text file in "/home/test.txt" in unix environment. How to open the same file & read using java code?
    - Hiren Modi

    http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • "Unable to read file" error in Excel 2010 when downloading .xls file from IE11

    We have lots of reports that have links for our users to be able to download report results in Excel format. We accomplish this by using the Excel mime type in our .asp pages. Sporadically, we are seeing "Unable to read file" errors in Excel 2010
    after choosing Open from the IE11 save dialog. Choosing Save/Save As and the file will open just fine.
    Also, we can sometimes cause the error to occur more frequently by switching windows during the time when the file is downloading.
    If the file is opened directly from /Temporary Internet Files then it opens just fine.
    Window 7 64-bit
    Thanks in advance!

    Hi,
    I found you replied in a similar thread, did you try the workaround (Reset the IE) that provided there? Did you change a browser to test?
    Then, I suggest we use Process Monitor to do further troubleshooting. Please collect all the actions of IE.exe and Excel.exe, and check the if there are some
    error message/code during you open XLS file from IE 11.
    Hope it's helpful.
    Regards,
    George Zhao
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • My NEF files used to open in camera raw 8.6 but now go straight to photoshop CS6? I don't have the option to edit them in camera raw? Help

    My nef files used to open in camera raw 8.6. Now when I drag and drop they go straight to photoshop cs6. I don't have the option to edit them in the camera raw editor! Help!

    Which operating system are you using?
    What is your screen resolution set at?

  • Im using xcode 4.6 and im having problems reading files using the fopen function in c

    Im using xcode 4.6 and im having problems reading files using the fopen function in c

    Yes, but that would not cause the "build  failed" message.
    right I missed that part. Looks like two problems then.
    //  main.m
    //  ASCTestFopen
    //  Created by Frank Caggiano on 3/2/13.
    //  Copyright (c) 2013 Frank Caggiano. All rights reserved.
    #import <Foundation/Foundation.h>
    #include <stdio.h> 
    int main(int argc, const char * argv[])
        @autoreleasepool {
            FILE *fp, *fopen();
            // insert code here...
            if((fp = fopen("~/test.txt","r")) == NULL)
                NSLog(@"open failed");
        return 0;
    This will compile ad run in Xcode with a project type of comand line tool

  • EP7.0 BI7 Report Export to excel - unable to read file

    Hello
    we have a EP7.0 portal that calls a BI7.0 BW report.
    Once the report is displayed and we select "export to excel" a pop up comes up and if we select "open" it calls MS Excel but then a pop up shows inside excel - "unable to read file".
    This also displays if we save the file locally then try and open it.
    Our Excel 2003 application is running on a citrix desktop.
    any help or ideas?
    Simon.

    Were you able to resolve this issue?  We are incurring now.

  • Error 16: unable to read file

    Hi,
    when opening this file in adobe acrobat x pro, everything goes well. But as soon as my employee starts to edit the file, like cutting a page out of it, he gets error 16: unable to read file. There's pretty no more information to give you, it's as simple as that?! It's with one file only, so far, others work great.
    Anyone any idea what is happening here?
    Thanks,

    Robert
    would there be any red flag, so to speak, other than file size, to tell me I've found what I'm looking for?Not knowing the program, I don't know what it might name its temporary files, if any, so size would be the best indicator.
    Is there any particular place I should look for the temporary fileWell, there are standard places where Unix puts temporary files, /tmp and /var/tmp, but you can't navigate to these by icon since they are normally invisible. However, in WhatSize …
    Click on the Folder icon, then (with cursor already in the Search box) type '/'. A sheet with "Go to the folder" drops down. Complete the path to say "/tmp" and click "Go", when you'll get a column view of the contents which you can navigate normally, then "Open" to see details. You can do the same with "/var/tmp". Probably the files you see here will be quite small, but you may be lucky.

  • HOW to read file using ftp???

    Hi to all,
    I have problem with reading file using ftp connection, i want to read only 1024 bytes for one time, and i have
    next code wich read this:
    byte buffer[] = new byte[1024];
    while( (readCount = input.read(buffer)) > 0) {
    bos.write(buffer, 0, readCount);
    but I dont know how to put all read data in one byte[] if i dont know length of file.
    I can't do some like: byte file[] = new file[1000000];
    Thanks for all sugestions!

          * Download a file from a FTP server. A FTP URL is generated with the following syntax:
         * <code>ftp://user:password@host:port/filePath;type=i</code>.
          * @param ftpServer FTP server address (incl. optional port ':portNumber').
          * @param user Optional user name to login.
          * @param pwd Optional password for <i>user</i>.
          * @param fileName Name of file to download (with optional preceeding relative path, e.g. one/two/three.txt).
          * @param destination Destination file to save.
         * @throws MalformedURLException, IOException on error.
         public void download(String ftpServer, String user, String pwd, String fileName, File destination) throws MalformedURLException, IOException {
            if (ftpServer != null && fileName != null && destination != null) {
                StringBuffer sb = new StringBuffer("ftp://");
                if (user != null && pwd != null) { //need authentication?
                    sb.append(user);
                    sb.append(':');
                    sb.append(pwd);
                    sb.append('@');
                }//else: anonymous access
                sb.append(ftpServer);
                sb.append('/');
                sb.append(fileName);
                sb.append(";type=i"); //a=ASCII mode, i=image (binary) mode, d= file directory listing
                BufferedInputStream bis = null;
                BufferedOutputStream bos = null;
                try {
                    URL url = new URL(sb.toString());
                    URLConnection urlc = url.openConnection();
                    bis = new BufferedInputStream(urlc.getInputStream());
                    bos = new BufferedOutputStream(new FileOutputStream(destination.getName()));
                    int i;
                    while ((i = bis.read()) != -1) { //read next byte until end of stream
                        bos.write(i);
                    }//next byte
                } finally {
                    if (bis != null) try { bis.close(); } catch (IOException ioe) { /* ignore*/ }
                    if (bos != null) try { bos.close(); } catch (IOException ioe) { /* ignore*/ }
            }//else: input unavailable
        }//download()If you don't want to strore the data into a file, use ByteArrayOutputStream instead of a FileOutputStream.

  • UCCX 8.0 CAD: Can you disable auto update? Error: "unable to download file" Could not open request.

    I have a UCCX 8.0 (2) Installed.
    Users here have limited access via proxy. Now everytime i try to run the CAD or CSD, i get the error:
    "unable to download file" Could not open request.
    It seems to want to install or check for an update.
    The work around i have found is to go to the CAD directory and change the update.exe filename
    C:\Program Files (x86)\Common Files\CAD\bin\update.exe
    i dont want to have to do this for every user as i possibly want the update.
    Is there a way to allow or bypass proxy on CAD?
    Regards
    J

    I had this problem before - to resolve it I disabled the proxy in internet explorer settings.
    You'll need to make sure the CAD version matches your UCCX server version. Otherwise you may run in to issues.
    Brian

  • Unable to read file

    I have a wedding project in Final cut express that was just about finish. It was left to render. When I came back the G5 had a system failure so I restarted. When it was back on I got into another project I was working on. Just a few minutes ago I tried to get into the first project and a message comes up saying "Unable to Read File" I can only click okay and when I do, I see the orignal project with none of my edits. What in the world happened? and how do I get my project back? This is very important.

    It looks like you did not have Autosave Vault turned on in User Preferences (which would have provided you with an earlier version of your project). I suggest that you make a Finder search in all Hard Drives, looking for the name of your failed project file, in case there is an earlier copy saved somewhere else. Perhaps you saved it by mistake somewhere else, or FCE did make an Autosave but put it somewhere else. I'm sorry, but I can't suggest anything else.
    But here's a thought: are you getting "Media Offline" in your failed project? If so, you could reconnect the clips in the Browser and Timeline to their sources in the Capture Scratch area
    Message was edited by: SteveKir

  • Unable to open file in emulator using Connector.open()

    This is my code (run on emulator) used to open a file located in the dir: C:\WTK25\appdb\DefaultColorPhone\filesystem\root1
    /**************************************CODE***********************************/
    FileConnection fileConn = (FileConnection)Connector.open("file:///root1/" fileName, Connector.READ);
    if(!fileConn.exists())
    System.out.println("File not found");
    else
    System.out.println("File opened");
    /**************************************CODE***********************************/
    I always get the o/p as "File Not Found" although there exists a .txt file in the directory /root1. What is to be done to open file on emulator? Please give suggestions...
    Message was edited by:
    Chintan.Kanal
    Message was edited by:
    Chintan.Kanal

    i m not sure but i hope this one is right 4 u......
    StringBuffer buff = new StringBuffer();
    InputStream istr = getClass().getResourceAsStream("/CLM.txt");
    for(int i=0 ; ; i++) {
    try {
    if(istr != null) {
    someByte = istr.read();
    if(someByte == -1) {
    buff.append("*");
    clmcontent = buff.toString();
    break;
    buff.append((char)someByte);
    } else {
    // do some necessary
    } catch(IOException ioe) {
    }

Maybe you are looking for