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

后端 未结 2 1171
猫巷女王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条回答
  •  Happy的楠姐
    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.

提交回复
热议问题