Back to project page VisEQ.
The source code is released under:
Copyright (c) 2012, Spotify AB All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:...
If you think the Android project VisEQ listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.lsu.vizeq; // w w w . j av a 2 s .c om import java.net.DatagramPacket; import android.util.Log; public class PacketParser { public static String getHeader(DatagramPacket packet) { String header = ""; String data = new String(packet.getData()); int nlindx = data.indexOf('\n'); if(nlindx < 0) nlindx = data.indexOf(0); header = data.substring(0,nlindx); return header; } public static String[] getArgs(DatagramPacket packet) { String[] args; String data = new String(packet.getData()); int numArgs = 0; // Log.d("packetparser", data); for(int i=0; i<data.length(); i++) { if(data.charAt(i)=='\n') numArgs++; } args = new String[numArgs]; int nlindx = data.indexOf('\n'); boolean end = false; int count = 0; while(!end) { String arg; data = data.substring(nlindx+1); nlindx = data.indexOf('\n'); if(nlindx < 0) { nlindx = data.indexOf(0); end = true; } arg = data.substring(0, nlindx); args[count++] = arg; } return args; } }