Page 1 of 2 12 LastLast
Results 1 to 20 of 30

Thread: File problem

  1. #1
    Blackberrylerner is offline Senior Member
    Join Date
    Jul 2010
    Posts
    101
    Rep Power
    0

    Default File problem

    Hi Member

    I am trying to read file and i did this with the help of forum.Now i have different type of problem.When i copy .cod and .alx file in phone through BlackBerry Desktop software and try to read file content then it's show blank.
    File Test.txt have two line Test and Testing.
    I add test.txt file through add project file(Resource folder).I use read file code is this.
    Java Code:
           try {
    
                //The class name is the fully qualified package name followed
    
                //by the actual name of this class
    
                Class classs = Class.forName("com.rim.samples.device.smsdemo.Test");
    
    
                //to actually retrieve the resource prefix the name of the file with a "/"
    
                InputStream is = classs.getResourceAsStream("/test.txt");
    
              
                //we now have an input stream. Create a reader and read out
    
                //each character in the stream.
    
                InputStreamReader isr = new InputStreamReader(is);
               
    
                int c;
               while ((c= isr.read()) != -1) 
               {
                   
                    System.out.print((char)c);
                   
                    
                  
                }
    
            } catch(Exception ex) {
    
                System.out.println("Error: " + ex.toString());
    
            }
    Please help me
    Last edited by Blackberrylerner; 08-16-2010 at 02:05 PM.

  2. #2
    Blackberrylerner is offline Senior Member
    Join Date
    Jul 2010
    Posts
    101
    Rep Power
    0

    Default

    Please help me..

  3. #3
    Sno's Avatar
    Sno
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Posts
    196
    Rep Power
    5

    Default

    What's your exception?
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

  4. #4
    Blackberrylerner is offline Senior Member
    Join Date
    Jul 2010
    Posts
    101
    Rep Power
    0

    Default

    Quote Originally Posted by Sno View Post
    What's your exception?
    No exception.
    Problem is when i put .cod and .alx file in phone and text file is in system(pc) and try to read text file then i have got only blank space.
    Please help me

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  6. #6
    Blackberrylerner is offline Senior Member
    Join Date
    Jul 2010
    Posts
    101
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    Can't you debug the code?
    Sir i debug the code then it's work perfect.But problem occur when i put .cod and .alx file in BlackBerry phone and .txt file is present in system(pc) in folder.Now i have change some line in .txt file then i start the application from blackberry.Then i am getting only old line.

    Please guide me how can i show full content of file.

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    I'm not clear what you mean by ".txt file is present in system(pc) in folder", you mean that the file not in the BB and in your PC?

  8. #8
    Blackberrylerner is offline Senior Member
    Join Date
    Jul 2010
    Posts
    101
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    I'm not clear what you mean by ".txt file is present in system(pc) in folder", you mean that the file not in the BB and in your PC?
    Yes file present in pc.

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    If you get the content in second attempt after change the content, means that your data may be cached somewhere. Comment on my previous post first of, I'm not clear with that.

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Blackberrylerner View Post
    Yes file present in pc.
    Fine, if your file is in the PC, then it's seems to me that data cached somewhere.

  11. #11
    Blackberrylerner is offline Senior Member
    Join Date
    Jul 2010
    Posts
    101
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    Fine, if your file is in the PC, then it's seems to me that data cached somewhere.
    sorry what you want to say please explain me in detail.

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    You said that, at first time you didn't get any content on the file. Then you change something on it and try to read it again, what happen? Previous content found. If you do this again and again, I think same thing is happen, always get the previous content. Is it clear and did you try that scenario?

  13. #13
    Blackberrylerner is offline Senior Member
    Join Date
    Jul 2010
    Posts
    101
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    You said that, at first time you didn't get any content on the file. Then you change something on it and try to read it again, what happen? Previous content found. If you do this again and again, I think same thing is happen, always get the previous content. Is it clear and did you try that scenario?
    Sorry for my post.
    You said that, at first time you didn't get any content on the file.
    I want to say modified content i havn't got.

    Again sorry for my wrong post again.
    Basically i want to do

    I want to read text file which is present in system(pc) folder through .cod file(which is present in BB device)
    Java Code:
    try {
    
                //The class name is the fully qualified package name followed
    
                //by the actual name of this class
    
                Class classs = Class.forName("com.rim.samples.device.smsdemo.Test");
    
    
                //to actually retrieve the resource prefix the name of the file with a "/"
    
                InputStream is = classs.getResourceAsStream("/test.txt");
    
              
                //we now have an input stream. Create a reader and read out
    
                //each character in the stream.
    
                InputStreamReader isr = new InputStreamReader(is);
               
    
                int c;
               while ((c= isr.read()) != -1) 
               {
                   
                    System.out.print((char)c);
                   
                    
                  
                }
    
            } catch(Exception ex) {
    
                System.out.println("Error: " + ex.toString());
    
            }
    If i am going in wrong direction then please guide me.
    Thanks in advance
    Last edited by Blackberrylerner; 08-17-2010 at 07:40 AM.

  14. #14
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Seems your code doesn't have any error actually. So that something wrong when you connect to PC, but wonder you didn't get any exception.

    Why you want to access a file on your PC, why cannot keep the file in BB.

  15. #15
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    And also make sure that getResourceAsStream() able to communicate through two devices like this. I've never try this, only in a single device I've use it.

  16. #16
    Blackberrylerner is offline Senior Member
    Join Date
    Jul 2010
    Posts
    101
    Rep Power
    0

    Default

    Ok as you know i am new in java.
    How can i store file in BB through code.I am using javaloader for store .code and .alx file in BB.But javaloader not working for file.
    So i try to access a file from PC.
    Please help me sir

  17. #17
    Blackberrylerner is offline Senior Member
    Join Date
    Jul 2010
    Posts
    101
    Rep Power
    0

    Default

    As you know i try to make SendSms through PC.So i put sms.cod file in BB device.And PC have GUI interface where user can enter Sender Number and Message.When you user click on send button that time i write number and message in file and call sms.cod file to read these file.
    Please help me

  18. #18
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  19. #19
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    If I'm get correctly, what you want to do is user type a message in BB and once click send button it should sent to the PC, and from there you want to send the message. Is it?

  20. #20
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Page 1 of 2 12 LastLast

Similar Threads

  1. jar file problem
    By abhijit in forum New To Java
    Replies: 12
    Last Post: 02-12-2010, 09:06 AM
  2. Jar File Problem
    By Moncleared in forum New To Java
    Replies: 10
    Last Post: 10-18-2009, 07:43 AM
  3. jar file problem
    By nishant.4545 in forum New To Java
    Replies: 1
    Last Post: 07-03-2009, 08:36 PM
  4. problem with jar file
    By biba84 in forum Advanced Java
    Replies: 7
    Last Post: 11-09-2008, 06:46 PM
  5. problem with jar file pls help
    By jinu5 in forum New To Java
    Replies: 0
    Last Post: 08-15-2007, 10:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •