import net.sf.openrocket.document.OpenRocketDocument;
import net.sf.openrocket.file.openrocket.importt.OpenRocketLoader;
import net.sf.openrocket.file.rocksim.importt.RocksimLoader;
+import net.sf.openrocket.util.ArrayUtils;
import net.sf.openrocket.util.TextUtil;
}
}
- byte[] typeIdentifier = Arrays.copyOf(buffer, ROCKSIM_SIGNATURE.length);
+ byte[] typeIdentifier = ArrayUtils.copyOf(buffer, ROCKSIM_SIGNATURE.length);
if (Arrays.equals(ROCKSIM_SIGNATURE, typeIdentifier)) {
return loadUsing(source, rocksimLoader, motorFinder);
}
*/
private Coordinate[] toCoordinates (String pointList, WarningSet warnings) {
List<Coordinate> result = new ArrayList<Coordinate>();
- if (pointList != null && !pointList.isEmpty()) {
+ if (pointList != null && pointList.length() > 0) {
String[] points = pointList.split("\\Q|\\E");
for (String point : points) {
String[] aPoint = point.split(",");
}
+ public static byte[] copyOf( byte[] original, int length ) {
+ return copyOfRange(original,0,length);
+ }
+
+ public static byte[] copyOfRange( byte[] original, int start, int end ) {
+
+ if ( original == null ) {
+ throw new NullPointerException();
+ }
+
+ if ( start < 0 || start > original.length ) {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
+ if ( start > end ) {
+ throw new IllegalArgumentException();
+ }
+
+ byte[] result = new byte[(end-start)];
+
+ int index = 0;
+ int stop = original.length < end ? original.length : end;
+ for ( int i = start; i < stop; i ++ ) {
+ if ( i < original.length ) {
+ result[index] = original[i];
+ }
+ index++;
+ }
+
+ return result;
+
+ }
+
}