BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-25-2008, 03:15 PM   #1 (permalink)
New Member
 
Join Date: Aug 2008
Model: 9000
PIN: N/A
Carrier: Kechen networks
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default opening and reading files on PC using Blackberry simulator

Please Login to Remove!

Hi,

I'm trying to write code to open a gzip file using the simulator. I keep getting a null pointer error.The file is stored on the C:\ drive on the PC. Below is the code we are using. Not sure if there is a solution but any help would be appreciated. I'm not sure if the simulator can access files on the PC. If not, is there an alternate solution? By the way, then null pointer occurs at "if(!fconn.exists())"

Thanks,
J

int length;
String filename = "file:///C:/workspace/gzip_test_app/test.txt.gz";
FileConnection fconn = null;
try {
fconn = (FileConnection) Connector.open(filename, Connector.READ);
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
if (!fconn.exists())
{
Dialog.alert("The file does not exist!");
}
else {
Dialog.alert("File has been foudn");

Last edited by jcher : 08-25-2008 at 03:16 PM. Reason: update
Offline  
Old 08-25-2008, 11:28 PM   #2 (permalink)
CrackBerry Addict
 
Join Date: May 2005
Location: Golden, CO US
Model: 9700
Carrier: ATT
Posts: 684
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can't read the pc filesystem directly but you can tell the simulator to map the SDCard to a directory on the PC. You can then access a file there by "file:///SDCard/...."
Offline  
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





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