Re: [android-beginners] IOException with BufferedReader

2009-12-15 Thread Yousuf Syed
Hi,

You cannot use the regular java IO for res/raw. folder.
only if you are using /sd/card you can use regular java.io

here is some code that might help you



FileInputStream fin = context.openFileInput(sitestore);
InputStreamReader br = new InputStreamReader(fin);
String readString = ;
int i;
while((i = br.read()) != -1){
inputBuffer = (char)i;
readString = readString + inputBuffer;
}

FileOutputStream fOut = context.openFileOutput(sitestore,
context.MODE_WORLD_READABLE);
OutputStreamWriter bw = new OutputStreamWriter(fOut);

write the code for writting to file here...


Regards,

Yousuf.
On Mon, Dec 14, 2009 at 4:03 PM, kaloer mkal...@gmail.com wrote:

 Hi,

 I have a problem when I'm trying to read a file from the res/raw
 folder. When I get the file as an InputStream and try reading it line
 for line with a BufferedReader, I get an IOException when I'm calling
 the br.readLine(). I do no get any additional information in the
 exception.
 Are there anything wrong with this code:


private void readFile(InputStream mFile) {
DataInputStream in = new DataInputStream(mFile);
BufferedReader br = new BufferedReader(new
 InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
Log.i(line, strLine);
}
in.close();
}

 Thank you very much!

 //Kaloer

 --
 You received this message because you are subscribed to the Google
 Groups Android Beginners group.
 To post to this group, send email to android-beginners@googlegroups.com
 To unsubscribe from this group, send email to
 android-beginners+unsubscr...@googlegroups.comandroid-beginners%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-beginners?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

[android-beginners] IOException with BufferedReader

2009-12-14 Thread kaloer
Hi,

I have a problem when I'm trying to read a file from the res/raw
folder. When I get the file as an InputStream and try reading it line
for line with a BufferedReader, I get an IOException when I'm calling
the br.readLine(). I do no get any additional information in the
exception.
Are there anything wrong with this code:


private void readFile(InputStream mFile) {
DataInputStream in = new DataInputStream(mFile);
BufferedReader br = new BufferedReader(new 
InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
Log.i(line, strLine);
}
in.close();
}

Thank you very much!

//Kaloer

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en