daily pastebin goal
43%
SHARE
TWEET

Untitled

a guest Jan 23rd, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ```java
  2.    public boolean sauvegarder(String fileName, String data) {
  3.         FileOutputStream output = null;
  4.         try {
  5.             output = openFileOutput(fileName, MODE_PRIVATE);
  6.             output.write(data.getBytes());
  7.             if(output != null) {
  8.                 output.close();
  9.             }
  10.             return true;
  11.         } catch (FileNotFoundException e) {
  12.             e.printStackTrace();
  13.         } catch (IOException e) {
  14.             e.printStackTrace();
  15.         }
  16.         return false;
  17.     }
  18.  
  19.     public String charger(String fileName){
  20.         String value = null;
  21.         FileInputStream inputStream= null;
  22.         try {
  23.             inputStream = openFileInput(fileName);
  24.  
  25.         StringBuilder stringb= new StringBuilder();
  26.         int content;
  27.  
  28.         while ((content=inputStream.read())!=-1){
  29.             value = String.valueOf(stringb.append((char)content));
  30.         }
  31.         } catch (FileNotFoundException e) {
  32.             e.printStackTrace();
  33.         } catch (IOException e) {
  34.             e.printStackTrace();
  35.         }
  36.         return value ;
  37.     }
  38. ```
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top