Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 写在sd卡上!Android,txt数据_Java_Android_Inputstream_Outputstream - Fatal编程技术网

Java 写在sd卡上!Android,txt数据

Java 写在sd卡上!Android,txt数据,java,android,inputstream,outputstream,Java,Android,Inputstream,Outputstream,启动应用程序时,我总是会收到以下日志: 12-17 14:52:02.688: E/ThrottleService(287): problem during onPollAlarm: java.lang.IllegalStateException: problem parsing stats: java.io.FileNotFoundException: /proc/net/xt_qtaguid/iface_stat_all: open failed: ENOENT (No such file

启动应用程序时,我总是会收到以下日志:

12-17 14:52:02.688: E/ThrottleService(287): problem during onPollAlarm: java.lang.IllegalStateException: problem parsing stats: java.io.FileNotFoundException: /proc/net/xt_qtaguid/iface_stat_all: open failed: ENOENT (No such file or directory)
我从我的主要活动开始,但在开始之前:

Charakter ch = new Charakter(MainActivity.this,1, 2);
然后,启动方法:

Intent intent = new Intent(MainActivity.this,Charakteruebersicht.class);
            startActivity(intent);
这里的特征是:

public class Charakteruebersicht extends Activity{

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.charakteruebersicht);
    TextView CT= (TextView) findViewById(R.id.tVCharakter);
    Charakter ch = new Charakter(Charakteruebersicht.this, 0, 0);
    Item it;
    Waffen waf = new Waffen();
    Rüstungen rüs = new Rüstungen();
    int waffe=waf.gibItem(ch.getaktuellerWaffenindex(Charakteruebersicht.this)).getWaffenschaden();
    int ruestung=rüs.gibItem(ch.getaktuellerRüstungsindex(Charakteruebersicht.this)).getRüstungswert();
    Log.d("Waffe", String.valueOf(waffe));
    Log.d("Rüstung", String.valueOf(ruestung));
    CT.setText("Der aktuelle Waffenschaden beträgt"+waffe +"!  Der aktuelle Rüstungswert beträgt:" +ruestung );[..]
这里有一个写和读无效:

private int leseWaffenindex(Context ct2) {
    String state = Environment.getExternalStorageState();
    File filesDir= new File(ct2.getCacheDir()+"/"+ "Waffen.txt");
     String datax = "0" ;
        try {

            FileInputStream fIn = new FileInputStream (filesDir) ;
            InputStreamReader isr = new InputStreamReader ( fIn ) ;
            BufferedReader buffreader = new BufferedReader ( isr ) ;

            String readString = buffreader.readLine ( ) ;
            while ( readString != null ) {
                datax =  readString ;
                readString = buffreader.readLine ( ) ;
            }

            isr.close ( ) ;
        } catch ( IOException ioe ) {
            ioe.printStackTrace ( ) ;
        }
        return Integer.parseInt(datax);
    }
private void writeWaffe(Context ct2, int aktuellerWaffenindex2) {
     File Meinspeicherort = new File(ct2.getCacheDir()+"/"+"Waffen.txt");
     BufferedWriter out=null;
     try {
        Meinspeicherort.createNewFile();
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    try {
        out = new BufferedWriter(new FileWriter(Meinspeicherort));
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
     try {

            out.write ( aktuellerWaffenindex2 ) ;
            out.flush ( ) ;


        } catch ( Exception e ) {
            e.printStackTrace ( ) ;
        }finally
        {
            try {
                out.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }   
       }
    }

您正试图打开位于系统文件夹中的文件。相反,您应该尝试在SD卡上或在应用程序的本地存储目录中创建一个文件


请阅读此帮助:

我建议您从现在开始用英语编写代码。做这件事有很多原因,其中一个原因是——如果你需要帮助,别人会更容易理解你在做什么。啊,好吧,我理解你,对不起;)!我希望这没问题,因为只有一些变量和数据名在德语中;)你能用英语在函数名等旁边添加注释吗:)我懂一点德语,但不懂Enough:PI假设记录的错误与你向我们展示的代码无关。你的应用程序工作吗?应用程序不工作,总是在我启动应用程序frooze时。。。。