Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```java
- public boolean sauvegarder(String fileName, String data) {
- FileOutputStream output = null;
- try {
- output = openFileOutput(fileName, MODE_PRIVATE);
- output.write(data.getBytes());
- if(output != null) {
- output.close();
- }
- return true;
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return false;
- }
- public String charger(String fileName){
- String value = null;
- FileInputStream inputStream= null;
- try {
- inputStream = openFileInput(fileName);
- StringBuilder stringb= new StringBuilder();
- int content;
- while ((content=inputStream.read())!=-1){
- value = String.valueOf(stringb.append((char)content));
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return value ;
- }
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement