BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 11-02-2011, 11:05 AM   #1 (permalink)
New Member
 
Join Date: Nov 2011
Model: 7100T
PIN: N/A
Carrier: Bike
Posts: 13
Post Thanks: 5
Thanked 0 Times in 0 Posts
Default How to Read and Show String in file txt

Please Login to Remove!

Excuse me , I have a problem

this is my code
---
byte[] data = null;
FileConnection fconn = null;
DataInputStream is = null;
try {
fconn = (FileConnection) Connector.open("file:///D:/IP.txt", Connector.READ);
is = fconn.openDataInputStream();
data = IOUtilities.streamToBytes(is);
oxi = new LabelField(data);
add(oxi);
---

my IP.txt have string "Local Host"

Then Build and Run

String "LocalHost"

is not show in my app

helpme ,

thanks
Offline  
Old 11-02-2011, 12:56 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default Re: How to Read and Show String in file txt

LabelField expects an Object that implement tostring().

This does not describe byte[]

Try creating a String object form the bytes.
Offline  
Old 11-03-2011, 02:37 AM   #3 (permalink)
New Member
 
Join Date: Nov 2011
Model: 7100T
PIN: N/A
Carrier: Bike
Posts: 13
Post Thanks: 5
Thanked 0 Times in 0 Posts
Default Re: How to Read and Show String in file txt

Quote:
Originally Posted by Dougsg38p View Post
LabelField expects an Object that implement tostring().

This does not describe byte[]

Try creating a String object form the bytes.
thanks but....

how to create String object from the bytes.
Offline  
Old 11-03-2011, 07:15 AM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default Re: How to Read and Show String in file txt

Are you kidding me?

From the javadoc:

String

public String(byte[] bytes)

Construct a new String by converting the specified array of bytes using the platform's default character encoding. The length of the new String is a function of the encoding, and hence may not be equal to the length of the byte array.
Parameters:
bytes - The bytes to be converted into characters
Since:
JDK1.1

--------------------------------------------------------------------------------
Offline  
The Following User Says Thank You to Dougsg38p For This Useful Post:
bankkab (11-06-2011)
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: How to Read and Show String in file txt
Thread Thread Starter Forum Replies Last Post
Losing Call Logs, SMS or Emails? Optimize your BB! How To Setup for max free memory! John Clark BlackBerry Help 1620 12-31-2012 06:43 AM
Mail read in Outlook show unread on BB NOLU BES Admin Corner 2 02-17-2010 10:27 AM
Read emails on BES do not show as Read on BB8830 roybeasley General Legacy Device Discussion 0 04-21-2008 05:17 AM
New 7130 sync errors sinverarity General Legacy Device Discussion 0 07-13-2006 11:28 AM
I want read messages from my client to show read on blackberry???? hartmas General BlackBerry Discussion 2 02-08-2006 10:37 AM





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.