BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 11-02-2011, 11:05 AM   #1
bankkab
New Member
 
Join Date: Nov 2011
Model: 7100T
PIN: N/A
Carrier: Bike
Posts: 13
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
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
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
bankkab
New Member
 
Join Date: Nov 2011
Model: 7100T
PIN: N/A
Carrier: Bike
Posts: 13
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
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
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  
Closed Thread



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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 1623 06-30-2022 04:06 PM
Mail read in Outlook show unread on BB NOLU BES Admin Corner 2 02-17-2010 11: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 11:37 AM


Vintage Apple Computer 4” Paper Cube Notepad Macintosh 80s 90s Office White picture

Vintage Apple Computer 4” Paper Cube Notepad Macintosh 80s 90s Office White

$39.95



Lot of 6 Vintage Apple Drawstring Bags For iPhone, Mac, Apple Watch, iPod picture

Lot of 6 Vintage Apple Drawstring Bags For iPhone, Mac, Apple Watch, iPod

$45.00



Retro 1951 Apple Computer Logo 0.7mm Ballpoint Black Ink Pen Gold Barrel picture

Retro 1951 Apple Computer Logo 0.7mm Ballpoint Black Ink Pen Gold Barrel

$56.41



VINTAGE 1994 Apple Black Toner Laser Writer Cartridge M 2473 G/A NEW SEALED picture

VINTAGE 1994 Apple Black Toner Laser Writer Cartridge M 2473 G/A NEW SEALED

$25.95



Vintage  Rainbow Logo Apple Post-It Sticky Notes 4

Vintage Rainbow Logo Apple Post-It Sticky Notes 4" Rare computer collectible

$39.99



Vintage Red Apple Six Drawer Storage Organizer File Cabinet  picture

Vintage Red Apple Six Drawer Storage Organizer File Cabinet

$35.00







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