From b9e8608fa4212479876e80c77bfb54193d395941 Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Fri, 29 Jan 2016 15:27:55 +0200 Subject: [PATCH] android binary read/write fixed --- apps/tests/file-system-tests.ts | 3 ++- file-system/file-system-access.android.ts | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/tests/file-system-tests.ts b/apps/tests/file-system-tests.ts index 871132a64..acdbb51e2 100644 --- a/apps/tests/file-system-tests.ts +++ b/apps/tests/file-system-tests.ts @@ -245,8 +245,9 @@ export var testFileReadWriteBinary = function () { if (platform.device.os === platform.platformNames.ios) { TKUnit.assertTrue(source.isEqualToData(destination)); } else { - TKUnit.assertEqual(source, destination); + TKUnit.assertEqual(new java.io.File(sourceFile.path).length(), new java.io.File(destinationFile.path).length()); } + destinationFile.removeSync(); // // ``` diff --git a/file-system/file-system-access.android.ts b/file-system/file-system-access.android.ts index d0aa7d1fa..8c7d94507 100644 --- a/file-system/file-system-access.android.ts +++ b/file-system/file-system-access.android.ts @@ -201,7 +201,7 @@ export class FileSystemAccess { try { var javaFile = new java.io.File(path); var stream = new java.io.FileInputStream(javaFile); - var bytes = new byte[javaFile.length()]; + var bytes = java.lang.reflect.Array.newInstance(java.lang.Byte.class.getField("TYPE").get(null), javaFile.length()); var dataInputStream = new java.io.DataInputStream(stream); dataInputStream.readFully(bytes); return bytes; @@ -212,11 +212,10 @@ export class FileSystemAccess { } } - public write(path: string, content: java.io.ByteArrayOutputStream, onError?: (error: any) => any) { + public write(path: string, bytes: native.Array, onError?: (error: any) => any) { try { var javaFile = new java.io.File(path); var stream = new java.io.FileOutputStream(javaFile); - var bytes = content.toByteArray(); stream.write(bytes, 0, bytes.length); stream.close(); } catch (exception) {