Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. File compteurFile = new File(directoryPath, compteurFileName);
  2. String dataContent = "";
  3. if (compteurFile.exists()){
  4. try {
  5. dataContent = getStringFromFile(new java.io.FileInputStream (compteurFile));
  6. } catch (FileNotFoundException e) {
  7. // TODO Auto-generated catch block
  8. e.printStackTrace();
  9. } catch (IOException e) {
  10. // TODO Auto-generated catch block
  11. e.printStackTrace();
  12. }
  13. }
  14.  
  15.  
  16. if(dataContent == null || dataContent.equals("")){
  17. dataContent = "1";
  18. }
  19. int compteur = Integer.parseInt(dataContent.trim());
  20. compteur++;
  21. try {
  22. PrintWriter fileWriterCompteur = new PrintWriter(new BufferedWriter (new FileWriter(directoryPath + compteurFileName)));
  23. fileWriterCompteur.println(new Integer(compteur));
  24. fileWriterCompteur.close();
  25. } catch (IOException e) {
  26. // TODO Auto-generated catch block
  27. e.printStackTrace();
  28. }
  29.  
  30.  
  31. return dataContent;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement