当前位置: 首页>>代码示例>>Java>>正文


Java Arrays.copyOfRange方法代码示例

本文整理汇总了Java中java.util.Arrays.copyOfRange方法的典型用法代码示例。如果您正苦于以下问题:Java Arrays.copyOfRange方法的具体用法?Java Arrays.copyOfRange怎么用?Java Arrays.copyOfRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Arrays的用法示例。


在下文中一共展示了Arrays.copyOfRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserializeObjectInstances

import java.util.Arrays; //导入方法依赖的package包/类
private static List<LWM2MObjectInstance> deserializeObjectInstances(byte[] tlv, int offset, List<LWM2MObjectInstance> list) {
    TypeIdLength til = TypeIdLength.createTypeIdLength(tlv, offset).deserialize();
    offset = til.offset;

    if (til.type == TYPE_OBJECT_INSTANCE) {
        List<LWM2MResource> instances = new ArrayList<>();
        byte[] nested = Arrays.copyOfRange(tlv, offset, offset + til.length);
        deserializeResources(nested, 0, instances);
        list.add (new LWM2MObjectInstance(LWM2MID.from(til.id), instances));
    } else {
        throw new IllegalArgumentException("Object instance is expected at index:" + offset);
    }

    offset += til.length;

    return offset < tlv.length ? deserializeObjectInstances(tlv, offset, list) : list;
}
 
开发者ID:ARMmbed,项目名称:java-coap,代码行数:18,代码来源:TLVDeserializer.java

示例2: readPacketFromDevice

import java.util.Arrays; //导入方法依赖的package包/类
void readPacketFromDevice(FileInputStream inputStream, byte[] packet) throws DaedalusVpnService.VpnNetworkException, SocketException {
    // Read the outgoing packet from the input stream.
    int length;

    try {
        length = inputStream.read(packet);
    } catch (IOException e) {
        throw new DaedalusVpnService.VpnNetworkException("Cannot read from device", e);
    }


    if (length == 0) {
        Log.w(TAG, "Got empty packet!");
        return;
    }

    final byte[] readPacket = Arrays.copyOfRange(packet, 0, length);

    handleDnsRequest(readPacket);
}
 
开发者ID:iTXTech,项目名称:Daedalus,代码行数:21,代码来源:UdpProvider.java

示例3: setCHR

import java.util.Arrays; //导入方法依赖的package包/类
@Override
protected void setCHR(byte[] chr){
	if(chr.length>0){
	CHRbanks = new byte[chr.length/0x1000][0x1000];
	for(int i=0;i*0x1000<chr.length;i++)
		CHRbanks[i]= Arrays.copyOfRange(chr, i*0x1000, (i*0x1000)+0x1000);
	CHR_ROM[0]=CHRbanks[0];
	CHR_ROM[1]=CHRbanks[1];
	}
	else{
		CHR_ROM[0]= new byte[0x1000];
		CHR_ROM[1]= new byte[0x1000];
		CHR_ram = true;
	}
	smallchrrom = CHR_ram || CHRbanks.length==2;
	
}
 
开发者ID:QuantumSoundings,项目名称:BassNES,代码行数:18,代码来源:MMC1.java

示例4: setCHR

import java.util.Arrays; //导入方法依赖的package包/类
@Override
protected void setCHR(byte[] chr){
	if(chr.length>0){
		CHRbanks = new byte[chr.length/0x1000][0x1000];
	for(int i=0;i*0x1000<chr.length;i++)
		CHRbanks[i]= Arrays.copyOfRange(chr, i*0x1000, (i*0x1000)+0x1000);
	CHR_ROM[0]=CHRbanks[0];
	CHR_ROM[1]=CHRbanks[1];
	}
	else{
		CHR_ROM[0]= new byte[0x1000];
		CHR_ROM[1]= new byte[0x1000];
		CHR_ram = true;
	}
}
 
开发者ID:QuantumSoundings,项目名称:BassNES,代码行数:16,代码来源:AxROM.java

示例5: copyIVdata

import java.util.Arrays; //导入方法依赖的package包/类
private byte[] copyIVdata(byte[] keyData, int keyLength)
		throws EncFSInvalidConfigException {
	int ivLength = keyData.length - keyLength;
	if (ivLength != IV_LENGTH_IN_BYTES) {
		throw new EncFSInvalidConfigException("Non-standard IV length");
	}
	return Arrays.copyOfRange(keyData, keyLength, keyLength + ivLength);
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:9,代码来源:EncFSVolume.java

示例6: decodeApicFrame

import java.util.Arrays; //导入方法依赖的package包/类
private static ApicFrame decodeApicFrame(ParsableByteArray id3Data, int frameSize,
    int majorVersion) throws UnsupportedEncodingException {
  int encoding = id3Data.readUnsignedByte();
  String charset = getCharsetName(encoding);

  byte[] data = new byte[frameSize - 1];
  id3Data.readBytes(data, 0, frameSize - 1);

  String mimeType;
  int mimeTypeEndIndex;
  if (majorVersion == 2) {
    mimeTypeEndIndex = 2;
    mimeType = "image/" + Util.toLowerInvariant(new String(data, 0, 3, "ISO-8859-1"));
    if (mimeType.equals("image/jpg")) {
      mimeType = "image/jpeg";
    }
  } else {
    mimeTypeEndIndex = indexOfZeroByte(data, 0);
    mimeType = Util.toLowerInvariant(new String(data, 0, mimeTypeEndIndex, "ISO-8859-1"));
    if (mimeType.indexOf('/') == -1) {
      mimeType = "image/" + mimeType;
    }
  }

  int pictureType = data[mimeTypeEndIndex + 1] & 0xFF;

  int descriptionStartIndex = mimeTypeEndIndex + 2;
  int descriptionEndIndex = indexOfEos(data, descriptionStartIndex, encoding);
  String description = new String(data, descriptionStartIndex,
      descriptionEndIndex - descriptionStartIndex, charset);

  int pictureDataStartIndex = descriptionEndIndex + delimiterLength(encoding);
  byte[] pictureData = Arrays.copyOfRange(data, pictureDataStartIndex, data.length);

  return new ApicFrame(mimeType, description, pictureType, pictureData);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:37,代码来源:Id3Decoder.java

示例7: getLevelData

import java.util.Arrays; //导入方法依赖的package包/类
public static String[] getLevelData(int level) {
    initLevelsOffsets();
    if (level < 1 || level > getLevelsCount()) {
        return null;
    } else {
        return Arrays.copyOfRange(LEVELS_DATA, levelsOffsets.get(level - 1) + 1, levelsOffsets.get(level));
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:9,代码来源:LevelData.java

示例8: setPRG

import java.util.Arrays; //导入方法依赖的package包/类
@Override
protected void setPRG(byte[] prg){
	PRG_ROM = new byte[4][0x2000];
	PRGbanks = new byte[prg.length/0x2000][0x2000];
	for(int i=0;i*0x2000<prg.length;i++){
		PRGbanks[i]=Arrays.copyOfRange(prg, i*0x2000, (i*0x2000)+0x2000);
	}
	PRG_ROM[0]=PRGbanks[0];
	PRG_ROM[1]=PRGbanks[1];
	PRG_ROM[2]=PRGbanks[PRGbanks.length-2];
	PRG_ROM[3]=PRGbanks[PRGbanks.length-1];
}
 
开发者ID:QuantumSoundings,项目名称:BassNES,代码行数:13,代码来源:VRC1.java

示例9: generate

import java.util.Arrays; //导入方法依赖的package包/类
/**
 * Generate address from private key.
 *
 * @param keys  private and public keys.
 * @param seed  seed.
 * @param chain chain.
 * @return address.
 */
private static Address generate(KeyPair keys, @Nullable final String seed, @NotNull final String chain) {
    final byte[] privKey = keys.getPrivate().getEncoded();
    final byte[] pubKey = keys.getPublic().getEncoded();

    final byte[] hashPubKey = Arrays.copyOfRange(Crypto.hashChain(pubKey), 0, 20);
    final byte[] unhashedAddress = ByteUtils.concat(new byte[]{(char) 1}, chain.getBytes(), hashPubKey);
    final byte[] addressHash = Arrays.copyOfRange(Crypto.hashChain(unhashedAddress), 0, 4);

    final String address = Base58.encode(ByteUtils.concat(unhashedAddress, addressHash));
    final String publicKey = Base58.encode(pubKey);
    final String privateKey = Base58.encode(privKey);
    return createRaw(address, publicKey, privateKey, seed);
}
 
开发者ID:Alezhka,项目名称:JWaves,代码行数:22,代码来源:Address.java

示例10: copyRange

import java.util.Arrays; //导入方法依赖的package包/类
public static byte[] copyRange(byte[] bytes,ByteRange range) {
    if(range.a < 0) {
        throw new ArrayIndexOutOfBoundsException("Range.a must be 0 or higher, was: " + range.a);
    }
    if(range.b > bytes.length) {
        throw new ArrayIndexOutOfBoundsException("Range.b must be smaller then array length "+bytes.length+", was: " + range.b);
    }
    return Arrays.copyOfRange(bytes,range.a,range.b);
}
 
开发者ID:IIlllII,项目名称:bitbreeds-webrtc,代码行数:10,代码来源:SignalUtil.java

示例11: readBytes

import java.util.Arrays; //导入方法依赖的package包/类
byte[] readBytes(int offset, int len) throws NTLMException {
    try {
        return Arrays.copyOfRange(internal, offset, offset + len);
    } catch (ArrayIndexOutOfBoundsException ex) {
        throw new NTLMException(NTLMException.PACKET_READ_ERROR,
                "Input message incorrect size");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:NTLM.java

示例12: Frame

import java.util.Arrays; //导入方法依赖的package包/类
/** Constructor: Receive data frame */
public Frame(byte[] frame) {
	this.preamble = Arrays.copyOfRange(frame, 0, 1);
	this.type = frame[2] >> 4;
	this.id = 0x07 & frame[2];
	this.typeId = frame[2];
	this.dataLength = frame[3];
	this.data = Arrays.copyOfRange(frame, 4, dataLength);
	this.checksum = frame[36];

	this.frame = frame;
}
 
开发者ID:AitorB,项目名称:POPBL_V,代码行数:13,代码来源:Frame.java

示例13: processSelectFile

import java.util.Arrays; //导入方法依赖的package包/类
protected byte[] processSelectFile(final byte[] command) {
    byte cla = command[0];
    byte ins = command[1];
    byte p1 = command[2];
    byte p2 = command[3];
    byte length = command[4];
    byte[] aid = Arrays.copyOfRange(command, 5, 5+length);

    if (Arrays.equals(aid, getAID())) {
        return SUCCESS;
    } else {
        return FAIL_FILE_NOT_FOUND;
    }
}
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:15,代码来源:BasicCard.java

示例14: create

import java.util.Arrays; //导入方法依赖的package包/类
public static IpSeeker create(final byte[] buffer) {

        //Head
        final ByteBuffer headBuf = ByteBuffer.wrap(buffer, 0, 4 * 258);
        final int headPos = headBuf.getInt();
        // we have 256 segments, and last is the end position
        final int[] segmentPos = new int[257];
        for (int i = 0; i < 257; i++) {
            segmentPos[i] = headBuf.getInt();
        }

        //Dict
        final String dictRaw = new String(Arrays.copyOfRange(buffer, headPos, segmentPos[0]), UTF_8);
        final String[] dict = StringUtil.splitc(dictRaw, '\001');

        dict[0] = null; // "None" => null

        //Segments
        final int[][] segments = new int[256][];
        final long[][] segmentIndexers = new long[256][];

        for (int i = 0; i < 256; i++) {
            int start = segmentPos[i];
            int end = segmentPos[i + 1];

            int len = (end - start) / 12; //(1 int + 1 long = 12 byte)

            int[] segment = new int[len];
            long[] segmentIndexer = new long[len];

            ByteBuffer buf = ByteBuffer.wrap(buffer, start, end - start);

            for (int j = 0; j < len; j++) {
                segment[j] = buf.getInt();
                segmentIndexer[j] = buf.getLong();
            }
            segments[i] = segment;
            segmentIndexers[i] = segmentIndexer;
        }

        //XXX 校验
        return new IpSeeker(dict, segments, segmentIndexers);
    }
 
开发者ID:febit,项目名称:febit,代码行数:44,代码来源:IpSeeker.java

示例15: run

import java.util.Arrays; //导入方法依赖的package包/类
public int run(String[] args) throws Exception {
	if (args.length < 2) {
        System.err.println("HdfsWriter [local input path] [hdfs output path]");
        return 1;
    }
    
	// Get the filename out of the file path
 String filename = args[0].substring(args[0].lastIndexOf('/') + 1,args[0].length());

 String dest = args[1];
 // Create the destination path including the filename.
 if (dest.charAt(dest.length() - 1) != '/') {
   dest = dest + "/" + filename;
 } else {
   dest = dest + filename;
 }
 
    String localInputPath = args[0];
    
    File inputPath = new File(localInputPath);
    Path outputPath = new Path(dest);
    
    if(!inputPath.exists()){
    	System.err.println("Input file does not exist!");
        return 1;
    }
    
    Configuration conf = getConf();
    System.out.println("configured filesystem = " + conf.get(FS_PARAM_NAME));
    
    FileSystem fs = FileSystem.get(conf);
    
    if (fs.exists(outputPath)) {
        System.err.println("Output path exists!");
        return 1;
    }
    
    InputStream is = new BufferedInputStream(new FileInputStream(localInputPath));
    OutputStream os = fs.create(outputPath);
    
    System.out.println("\nKuber encryption started!\n");
    
    byte[] b = new byte[1024*100];
    
 int numBytes = 0;
 
 while ((numBytes = is.read(b)) > 0) {
   byte[] block = Arrays.copyOfRange(b, 0, numBytes);
   byte[] encrypted = encrypt(block);
   os.write(encrypted, 0, numBytes);
 }
 
 is.close();
 os.close();
 
    return 0;
}
 
开发者ID:rj97,项目名称:kuber,代码行数:58,代码来源:Encrypt.java


注:本文中的java.util.Arrays.copyOfRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。