[WooreeINFO] DataOutputStream API error

Dear MicroEJ,

While one of our software engineers has been trying to add some test code of DataOutputStream in your hello sample application, he met the errors as:

=============== [ Initialization Stage ] ===============
=============== [ Converting fonts ] ===============
=============== [ Converting images ] ===============
=============== [ Build Application ] ===============
1 : KERNEL/FEATURE ERROR [com.is2t.java.io.IFileSystem]

FAIL
Soar image generation aborted.

[M7] - Kernel type com.is2t.java.io.IFileSystem cannot access type [Ljava.io.File; (owned by Feature D:\Work\MicroEJ-Studio-4.1.5\com.microej.demo.hello\bin/hello.kf).
2 : KERNEL/FEATURE ERROR [com.is2t.java.io.IFileSystem]
[M7] - Kernel type com.is2t.java.io.IFileSystem cannot access type java.io.File (owned by Feature D:\Work\MicroEJ-Studio-4.1.5\com.microej.demo.hello\bin/hello.kf).
3 : KERNEL/FEATURE ERROR [com.is2t.java.io.IFileSystem]
[M7] - Kernel type com.is2t.java.io.IFileSystem cannot access type java.io.File (owned by Feature D:\Work\MicroEJ-Studio-4.1.5\com.microej.demo.hello\bin/hello.kf).
4 : KERNEL/FEATURE ERROR [com.is2t.java.io.IFileSystem]
[M7] - Kernel type com.is2t.java.io.IFileSystem cannot access type java.io.File (owned by Feature D:\Work\MicroEJ-Studio-4.1.5\com.microej.demo.hello\bin/hello.kf).
5 : KERNEL/FEATURE ERROR [com.is2t.java.io.IFileSystem]
[M7] - Kernel type com.is2t.java.io.IFileSystem cannot access type java.io.File (owned by Feature D:\Work\MicroEJ-Studio-4.1.5\com.microej.demo.hello\bin/hello.kf).
6 : KERNEL/FEATURE ERROR [com.is2t.java.io.IFileSystem]
[M7] - Kernel type com.is2t.java.io.IFileSystem cannot access type java.io.File (owned by Feature D:\Work\MicroEJ-Studio-4.1.5\com.microej.demo.hello\bin/hello.kf).
7 : KERNEL/FEATURE ERROR [com.is2t.java.io.IFileSystem]
[M7] - Kernel type com.is2t.java.io.IFileSystem cannot access type java.io.File (owned by Feature D:\Work\MicroEJ-Studio-4.1.5\com.microej.demo.hello\bin/hello.kf).
8 : KERNEL/FEATURE ERROR [com.is2t.java.io.IFileChannel$OpenMode]
[M7] - Kernel type com.is2t.java.io.IFileChannel$OpenMode cannot access type [Lcom.is2t.java.io.IFileChannel$OpenMode; (owned by Feature D:\Work\MicroEJ-Studio-4.1.5\com.microej.demo.hello\bin/hello.kf).
9 : KERNEL/FEATURE ERROR [com.is2t.java.io.IFileChannel$OpenMode]
[M7] - Kernel type com.is2t.java.io.IFileChannel$OpenMode cannot access type [Lcom.is2t.java.io.IFileChannel$OpenMode; (owned by Feature D:\Work\MicroEJ-Studio-4.1.5\com.microej.demo.hello\bin/hello.kf).
10 : KERNEL/FEATURE ERROR [com.is2t.java.io.IFileChannel$OpenMode]
[M7] - Kernel type com.is2t.java.io.IFileChannel$OpenMode cannot access type [Lcom.is2t.java.io.IFileChannel$OpenMode; (owned by Feature D:\Work\MicroEJ-Studio-4.1.5\com.microej.demo.hello\bin/hello.kf).
11 : KERNEL/FEATURE ERROR [java.io.FileOutputStream]
[M18] - Type java.io.FileOutputStream (owned by Feature D:\Work\MicroEJ-Studio-4.1.5\com.microej.demo.hello\bin/hello.kf) cannot access Kernel type com.is2t.java.io.IFileSystem (not an API). Found 54 occurrence(s).
12 : KERNEL/FEATURE ERROR [java.io.FileOutputStream]
[M18] - Type java.io.FileOutputStream (owned by Feature D:\Work\MicroEJ-Studio-4.1.5\com.microej.demo.hello\bin/hello.kf) cannot access Kernel type com.is2t.java.io.IFileChannel$OpenMode (not an API). Found 3 occurrence(s).
13 : KERNEL/FEATURE ERROR [java.io.FileOutputStream]
[M18] - Type java.io.FileOutputStream (owned by Feature D:\Work\MicroEJ-Studio-4.1.5\com.microej.demo.hello\bin/hello.kf) cannot access Kernel type com.is2t.java.io.IFileChannel (not an API). Found 5 occurrence(s).

The test code he added was as:

public void writeFile() {

DataOutputStream dos = null;

try {

	File file = new File("./hello");
	String contents = "test!!";
	dos = new DataOutputStream(new FileOutputStream(file));
	dos.write(contents.getBytes());
	
} catch (Exception ex) {
	ex.printStackTrace();
} finally {
	try {
		if (dos != null) {
			dos.close();
		}
	} catch (Exception ex) {
	}
}

}

Could you please advise me about where he has some of misunderstanding here?

Thanks much in advance.

Regards
YH Kwon

Hi @kwonyh,

You cannot access the File APIs in the firmware that you have, it is restricted. Depending on the firmware that you are using check if you have the Storage API [1] for persistence purpose.

Gaëtan.

[1] https://github.com/MicroEJ/How-To/tree/master/Storage-Get-Started

Dear Gaëtan Harel,

Thanks for your quick feedback first of all, and please be noted that his firmware is one of your reference, STM32F746G-DISCO, at the URL as:

http://developer.microej.com/getting-started-stm.html

In addition my question back would be if the example of ‘Storage-Get-Started’, in your feedback, does support reading and/or writing files using the File API or not.

Regards
YH Kwon

In the storage API you have two main methods store and load that are acting respectively as writing and reading. Depending on the Storage back-end implementation for the firmware it will go in a filesystem in SDCard, in flash or any storage.
In the STM32F746G-DISCO firmware it will go in a filesystem on the SDCard under /usr/storage/features/${featureID} where ${featureID} depends on the multi-sandboxed app ID you used.

Gaëtan

Dear Gaëtan Harel,

Thanks for your continued support on this, and my additional question here would be as:

Do you think if we can handle the folder(s) and the date & time when the file has been created/written?

Thanks again
YH Kwon

The Storage API has been designed with absolute simplicity in mind (in case the back-end implementation is something limited, typically not a filesystem). It does not support date and time properties like a filesystem like FAT32 filesystem would.
However, you can use the key of the Storage API to add the metadata (embed the date, time and folder in the key for example).

Gaëtan