In Codename One, why can I not get FileInputStream to import or compile?

后端 未结 2 1155
猫巷女王i
猫巷女王i 2021-01-28 07:49

Here are my imports:

import com.codename1.ui.*;
import com.codename1.ui.util.*;
import com.codename1.ui.plaf.*;
import com.codename1.ui.events.*;
import com.code         


        
相关标签:
2条回答
  • 2021-01-28 08:15

    It looks like Codename One has omitted that class - and others, I suspect.

    Judging by the documentation, I suspect you want to use the com.codename1.io.FileSystemStorage class and its openInputStream method.

    You may well want to watch the video on storing data to persistent storage too.

    0 讨论(0)
  • 2021-01-28 08:22

    Jon's answer is correct but partial. The question is where is the CSV file actually stored...

    If the file is in the src folder (part of your jar) use Display.getInstance().getResourceAsStream(getClass(), "/filename");.

    If you downloaded it, then its very likely you downloaded to storage and not necessarily file system (slightly different things in mobile). Both have rather detailed API's to open/write and the Util class has a nice download API. Keep in mind that you can't just "put" a file on the device like you can in a computer, the filesystem is quite different.

    As a sidenote, Codename One has a builtin CSVParser class which could be useful for you.

    0 讨论(0)
提交回复
热议问题