Created
August 9, 2016 05:22
-
-
Save rahulupadhyay/b896826aa57e545aed14b4dad4568dea to your computer and use it in GitHub Desktop.
Create a CSV file using java with Calendar to create directories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Calendar c = Calendar.getInstance(); | |
int mon = (c.get(Calendar.MONTH))+1; | |
String monthpath = ""+mon; | |
String yearpath=""+c.get(Calendar.YEAR); | |
String datepath=""+c.get(Calendar.DATE); | |
String monthyear = monthpath.trim()+" "+yearpath.trim(); | |
int i=1; | |
Boolean check = isSdPresent(); | |
//Toast.makeText(getApplicationContext(), "SDCARD Mounted?\n"+check, Toast.LENGTH_SHORT).show(); | |
if(check.TRUE) | |
{ | |
File path = new File("/sdcard/Attendance/"+monthyear+"/"+datepath+"/"); | |
path.mkdirs(); | |
Toast.makeText(getApplicationContext(), "path created"+path, Toast.LENGTH_SHORT).show(); | |
store = c.get(Calendar.HOUR)+"_"+c.get(Calendar.MINUTE)+"_"+c.get(Calendar.SECOND)+"_"+string2; | |
//dispDate = "Date: "+datepath+"/"+monthpath+"/"+yearpath+"\tTime: "+store; | |
//Toast.makeText(getApplicationContext(), store, Toast.LENGTH_LONG).show(); | |
//FileOutputStream fo = new FileOutputStream(path+"/_File.csv"); | |
FileOutputStream fo = new FileOutputStream(path+"/"+recBranch+"_"+recFaculty+"_"+store+"File.csv"); | |
//Toast.makeText(getApplicationContext(), "Going to write"+fo, Toast.LENGTH_SHORT).show(); | |
fo.write(string.getBytes()); | |
//Toast.makeText(getApplicationContext(), "Successfully Stored, FileName/n"+recBranch+"_"+recFaculty+"_"+store,Toast.LENGTH_SHORT).show(); | |
fo.close(); | |
Toast.makeText(getApplicationContext(), "File Stored at"+path+"/", Toast.LENGTH_LONG).show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment