Java tutorial
//package com.java2s; /* * This is the source code of Telegram for Android v. 1.7.x. * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * * Copyright Nikolai Kudashov, 2013-2014. */ public class Main { private static String getTrimmedString(String src) { String result = src.trim(); if (result.length() == 0) { return result; } while (src.startsWith("\n")) { src = src.substring(1); } while (src.endsWith("\n")) { src = src.substring(0, src.length() - 1); } return src; } }