You Are Here:

Community: Developer Discussion Boards

#1 Old URGENT: Reading File from memory card problem - 2008-03-07, 10:54

Join Date: Mar 2008
Posts: 1
umarbasha
Offline
Registered User
I am trying to read the mp3 file from memory card using FileConnection APIs in J2ME. When i use read() call, it throws "Native error" and "Operation in Progress" Exception. Can someone suggest what the code needs to be as the code is in line?

FileConnection fc = (FileConnection)Connector.open(file_path, Connector.READ);

if (!fc.exists()){
Log.out("File does not exit");
throw new IOException("File Does not exist");
}
InputStream is = fc.openInputStream();

fileSize = fc.fileSize();
hs.setHeader(HeaderSet.NAME, media.getNameWithExt());
hs.setHeader(HeaderSet.TYPE, "audio/mp3");
hs.setHeader(HeaderSet.LENGTH, new Long(fileSize));
Operation putOperation = cs.put(hs);
OutputStream outputStream = putOperation.openOutputStream();

Log.out("The size of the file is :" + fileSize);

while(readLength < fileSize){
if(fileSize-readLength < 1024)
length = (int)fileSize - readLength;
else
length = 1024;
Log.out("The size of the length is:"+ length);
in = new byte[(int)length];
Log.out("array created successfully");

int bytesRead=0;
int current=0;
do{
bytesRead = is.read(in, current, in.length-current-1);

if (bytesRead > 0)
current += bytesRead;
}while (bytesRead > 0);

outputStream.write(in, 0, current);
outputStream.flush();
readLength += length;
}

outputStream.close();
putOperation.close();
fc.close();
}
catch(Exception e){
e.printStackTrace();
}
Reply With Quote

#2 Old Re: URGENT: Reading File from memory card problem - 2008-03-07, 11:30

Join Date: Apr 2003
Posts: 6,408
Location: USA, CA
hartti's Avatar
hartti
Offline
Nokia Expert
Which device are you talking about?
Do you have some other applications running on the background and reading the file?
So you do not get any security exceptions, right?

Hartti
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in Reading a file using RFileReadStream ash_21 General Symbian C++ 15 2007-10-24 14:47
Error with makesis.exe and creating the .pkg file gramya87 Symbian Tools & SDKs 7 2007-10-10 14:53
Phone not reading memory card on 6630 crazymofo General Discussion 3 2007-10-08 17:27
Problem with reading a file........ rafeeqpv General Symbian C++ 0 2005-11-15 14:09
problem about Reading data from a RESOURCE FILE to an application windalfred0 Symbian 8 2004-06-16 09:38

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ