2

ボタンの位置 (MainMenu.Menu_Options) をプロパティ ファイルに保存し、それも読みたいので、問題があります。これどうやってするの?getLocation() を使用できることはわかっていますが、それを文字列に変換する必要があります。コード:

try{
        options.setProperty("firstbackcolor", firstbackgroundColor.toString());
        options.setProperty("secondbackcolor", secondbackgroundColor.toString());
        options.setProperty("firsttext", firsttextColor.toString());
        options.setProperty("secondtext", secondtextColor.toString());
        options.setProperty("Slot_Options", MainMenu.Menu_Options.getLocation());


        options.store(new FileOutputStream(SupremeDataPath),null);
    }catch(Exception e){}

誰でも?

4

1 に答える 1

1

場所を保存するために使用されるプロパティ ファイルを読みたい場合は、次のようにすることができます。

     // read from properties file
    Properties properties = new Properties();

    try {
        File file = new File("path here");
        properties.load(new FileInputStream(file));
    } catch (IOException e) {
        e.printStackTrace();
    }

    String location = (String) properties.get("key.to.location");

    // write to properties file
    properties.setProperty("key.new.location", "new location");
    properties.store(new FileOutputStream(file), "comment");
于 2013-09-10T17:46:19.847 に答える