saveStrings() loadStrings()

edited July 2015 in How To...

How can i save in the data folder, or load from the sketch folder? To save a highscore for example. Thanks.

Answers

  • Answer ✓
    String a1 = "hello"; 
    
    String b1 = "Good bye";
    
    size (220, 200); 
    
    println (b1) ;
    
    // ------------------------------------
    // save 
    
    String[] arrString1 = new String [1];
    
    arrString1[0] = a1; 
    
    String path1 = dataPath("")  + "\\re.txt";  // or sketchPath("")   
    
    saveStrings(path1, arrString1); // save   
    
    arrString1 = null; 
    
    // ---------------------------------------
    // load 
    
    String[] arrString2 = loadStrings(path1); // load  
    
    b1 = arrString2[0];
    
    println (b1) ;
    
  • Thank youu!

Sign In or Register to comment.