當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。