/** * Copyright 2012 Neurowork Consulting S.L. * * This file is part of eMobc. * * Utils.java * eMobc Android Framework * * eMobc is free software: you can redistribute it and/or modify * it under the terms of the Affero GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * eMobc is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the Affero GNU General Public License * along with eMobc. If not, see <http://www.gnu.org/licenses/>. * */ package com.emobc.android.utils; import java.io.InputStream; import java.io.OutputStream; /** * Utility class * @author Jorge E. Villaverde * @version 0.1 * @since 0.1 */ public class Utils { /** * Copies the bytes from the InputStream to the OutputStream using a buffer. * @param is InputStream to copy from. * @param os OutputStream to copy to. */ public static void copyStream(InputStream is, OutputStream os) { final int buffer_size = 1024; try { byte[] bytes = new byte[buffer_size]; for (;;) { int count = is.read(bytes, 0, buffer_size); if (count == -1) break; os.write(bytes, 0, count); } } catch (Exception ex) { } } public static boolean hasLength(String text) { if(text != null) return (text.trim().length() > 0); return false; } /** * Returns true if the imageFile name starts with <code>http://</code> or <code>https://</code> * @param imageFile * @return */ public static boolean isUrl(String imageFile){ if (imageFile != null) { if(imageFile.startsWith("http://")||imageFile.startsWith("https://")){ return true; }else{ return false; } } return false; } }