100town wrote:
> Hi,
>
> I am in the problem about reading data from some new file extensions,
> the problem is fis.read() gets -1 from the first run without and
> exceptions being thrown. Check the code below:
> String path = “/sdcard/wanshuiqianshan.lrc”;
> java.io.FileInputStream fis = null;
> try{
> fis= new java.io.FileInputStream(path);
> int c=0;
> StringBuffer sb=new StringBuffer();
> while(((c=fis.read())!=-1)){
> sb.append((char)c);
> }
> Log.e("INFO", "Here 1”);
> return sb.toString();
> }catch(Exception ioe){
> Log.e("EROOR", "file: "+path, ioe);
> return null;
> }finally{
> try{
> fis.close();
> }catch(Exception e){
> }
> }
> If I change the file extension to “txt”, everything is all right. I
> debugged into the android source then the code running into the native
> C code so not any clue was found.
>
> I searched in the group. Only some discuss leads to the cycle about
> mime-type and file extensions which cannot help me.
> I guess it is a build-in security mechanism about the undefined file
> extension types. Can anybody help? Thanks.
The lrc->txt file extension change makes no sense to me.
That being said, try a better file-reading algorithm and see if it helps:
http://exampledepot.com/egs/java.io/ReadLinesFromFile.html
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
Warescription: Three Android Books, Plus Updates, $35/Year
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---