Java examples for java.lang:byte Array
Returns the index at which '\n' is found. in byte array
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { byte[] buff = new byte[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 }; int from = 2; System.out.println(findN(buff, from)); }//from ww w.j a v a2 s . com /** * Returns the index at which '\n' is found. * * @param buff * @param from index to start from * @return -1 */ public static final int findN(byte[] buff, int from) { final int len = buff.length; for (int i = from; i < len; i++) { if (buff[i] == '\n') return i; } return -1; } }