Skip to content

Commit

Permalink
CMFileManager: Fix ReadCommand incompatible buffer
Browse files Browse the repository at this point in the history
Replace Reader buffer for InputStream buffer for avoid incomplatible char[] -> byte[] conversion.

Change-Id: Ic916f55e5b0be96d1b4ffef36ddd5d5858ea3fdc
  • Loading branch information
jruesga committed Nov 19, 2012
1 parent 02f052f commit 463b0da
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/com/cyanogenmod/filemanager/commands/java/ReadCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import com.cyanogenmod.filemanager.console.InsufficientPermissionsException;
import com.cyanogenmod.filemanager.console.NoSuchFileOrDirectory;

import java.io.BufferedReader;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileReader;
import java.io.FileInputStream;

/**
* A class for read a file.
Expand Down Expand Up @@ -121,12 +121,12 @@ public void execute()
*/
private void read(File file) {
// Read the file
BufferedReader br = null;
BufferedInputStream bis = null;
try {
br = new BufferedReader(new FileReader(file), getBufferSize());
bis = new BufferedInputStream(new FileInputStream(file), getBufferSize());
int read = 0;
char[] data = new char[getBufferSize()];
while ((read = br.read(data, 0, getBufferSize())) != -1) {
byte[] data = new byte[getBufferSize()];
while ((read = bis.read(data, 0, getBufferSize())) != -1) {
if (this.mAsyncResultListener != null) {
byte[] readData = new byte[read];
System.arraycopy(data, 0, readData, 0, read);
Expand Down Expand Up @@ -154,8 +154,8 @@ private void read(File file) {

} finally {
try {
if (br != null) {
br.close();
if (bis != null) {
bis.close();
}
} catch (Throwable _throw) {/**NON BLOCK**/}
}
Expand Down

0 comments on commit 463b0da

Please sign in to comment.