Back to project page ChallengeYourFriends.
The source code is released under:
GNU General Public License
If you think the Android project ChallengeYourFriends listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.cyf.challengeyourfriends; //from ww w . j av a 2s .c o m import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.Scanner; import android.content.Context; import android.util.Log; public class FriendMan { private File fileFriendsList; private String friendsListName = "friendsList.txt"; FileOutputStream outputStream; public FriendMan(Context context) { fileFriendsList = new File(context.getFilesDir(), friendsListName); if (!fileFriendsList.exists()) try { fileFriendsList.createNewFile(); } catch (IOException e) { log("Friends list create failed"); e.printStackTrace(); } try { PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(friendsListName, true))); out.println("the text"); out.println("the text"); out.close(); } catch (IOException e) { //exception handling left as an exercise for the reader } log("###################################\n\n\n\n\n\n\n"); try { Scanner sc = new Scanner(fileFriendsList); while(sc.hasNext()){ log(sc.next()); } log("file end"); sc.close(); } catch (FileNotFoundException e) { log("friend file open failed"); e.printStackTrace(); } } void log(String str){ Log.w("Friends",str); } }