Android Open Source - Android-VKontakte-SDK Utils






From Project

Back to project page Android-VKontakte-SDK.

License

The source code is released under:

MIT License

If you think the Android project Android-VKontakte-SDK 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.perm.utils;
/*from   w ww  .  j ava 2  s .c  o m*/
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.StringWriter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Utils {
    
    public static String extractPattern(String string, String pattern){
        Pattern p = Pattern.compile(pattern);
        Matcher m = p.matcher(string);
        if (!m.find())
            return null;
        return m.toMatchResult().group(1);
    }
    
    public static String convertStreamToString(InputStream is) throws IOException {
        InputStreamReader r = new InputStreamReader(is);
        StringWriter sw = new StringWriter();
        char[] buffer = new char[1024];
        try {
            for (int n; (n = r.read(buffer)) != -1;)
                sw.write(buffer, 0, n);
        }
        finally{
            try {
                is.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        }
        return sw.toString();
    }
    
    public static void closeStream(Object oin) {
        if(oin!=null)
            try {
                if(oin instanceof InputStream)
                    ((InputStream)oin).close();
                if(oin instanceof OutputStream)
                    ((OutputStream)oin).close();
            } catch (IOException e) {
                e.printStackTrace();
            }
    }
    
    private static String pattern_string_profile_id = "^(id)?(\\d{1,10})$";
    private static Pattern pattern_profile_id = Pattern.compile(pattern_string_profile_id);
    public static String parseProfileId(String text) {
        Matcher m = pattern_profile_id.matcher(text);
        if (!m.find())
            return null;
        return m.group(2);
    }
}




Java Source Code List

com.perm.kate.api.Album.java
com.perm.kate.api.Api.java
com.perm.kate.api.Attachment.java
com.perm.kate.api.AudioAlbum.java
com.perm.kate.api.Audio.java
com.perm.kate.api.Auth.java
com.perm.kate.api.BanInfo.java
com.perm.kate.api.BannArg.java
com.perm.kate.api.City.java
com.perm.kate.api.CommentList.java
com.perm.kate.api.Comment.java
com.perm.kate.api.Constants.java
com.perm.kate.api.Contact.java
com.perm.kate.api.Counters.java
com.perm.kate.api.Country.java
com.perm.kate.api.Document.java
com.perm.kate.api.FriendsList.java
com.perm.kate.api.Geo.java
com.perm.kate.api.Gift.java
com.perm.kate.api.Graffiti.java
com.perm.kate.api.GroupBanItem.java
com.perm.kate.api.GroupTopic.java
com.perm.kate.api.Group.java
com.perm.kate.api.IdsPair.java
com.perm.kate.api.KException.java
com.perm.kate.api.LastActivity.java
com.perm.kate.api.Link.java
com.perm.kate.api.Media.java
com.perm.kate.api.Message.java
com.perm.kate.api.NameCases.java
com.perm.kate.api.NewsItem.java
com.perm.kate.api.NewsJTags.java
com.perm.kate.api.NewsTypes.java
com.perm.kate.api.Newsfeed.java
com.perm.kate.api.Note.java
com.perm.kate.api.Notification.java
com.perm.kate.api.Notifications.java
com.perm.kate.api.Page.java
com.perm.kate.api.Params.java
com.perm.kate.api.PhotoComment.java
com.perm.kate.api.PhotoTag.java
com.perm.kate.api.Photo.java
com.perm.kate.api.Place.java
com.perm.kate.api.Reply.java
com.perm.kate.api.SearchDialogItem.java
com.perm.kate.api.User.java
com.perm.kate.api.Video.java
com.perm.kate.api.VkApp.java
com.perm.kate.api.VkPollAnswer.java
com.perm.kate.api.VkPoll.java
com.perm.kate.api.VkStatus.java
com.perm.kate.api.WallMessage.java
com.perm.kate.api.sample.Account.java
com.perm.kate.api.sample.Constants.java
com.perm.kate.api.sample.LoginActivity.java
com.perm.kate.api.sample.MainActivity.java
com.perm.utils.Utils.java
com.perm.utils.WrongResponseCodeException.java