BlackBerry Forums Support Community

Closed Thread
LinkBack Thread Tools
Old 08-25-2008, 02:15 PM   #1 (permalink)
New Member
Join Date: Aug 2008
Model: 9000
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!


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())"


int length;
String filename = "file:///C:/workspace/gzip_test_app/test.txt.gz";
FileConnection fconn = null;
try {
fconn = (FileConnection), 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 02:16 PM. Reason: update
Old 08-25-2008, 10: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

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/...."

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