Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- File compteurFile = new File(directoryPath, compteurFileName);
- String dataContent = "";
- if (compteurFile.exists()){
- try {
- dataContent = getStringFromFile(new java.io.FileInputStream (compteurFile));
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- if(dataContent == null || dataContent.equals("")){
- dataContent = "1";
- }
- int compteur = Integer.parseInt(dataContent.trim());
- compteur++;
- try {
- PrintWriter fileWriterCompteur = new PrintWriter(new BufferedWriter (new FileWriter(directoryPath + compteurFileName)));
- fileWriterCompteur.println(new Integer(compteur));
- fileWriterCompteur.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return dataContent;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement