Android Open Source - ChallengeYourFriends Friend Man






From Project

Back to project page ChallengeYourFriends.

License

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.

Java Source Code

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);
    
  }
}




Java Source Code List

.ChallengeArchive.java
.ChallengeFriends.java
.Challenge.java
.CreateChallenge.java
.LogIn.java
.LogOut.java
.User.java
com.cyf.challengeyourfriends.ChallengeFriend.java
com.cyf.challengeyourfriends.ChooseFriendDialog.java
com.cyf.challengeyourfriends.ChooseFriendFrag.java
com.cyf.challengeyourfriends.FriendMan.java
com.cyf.challengeyourfriends.LoginActivity.java
com.cyf.challengeyourfriends.MainActivity.java
com.cyf.challengeyourfriends.MenuActivity.java
com.cyf.challengeyourfriends.ViewChallenges.java
.test.java