Created
April 10, 2017 09:05
-
-
Save hn5092/dba7da0e9afd7743105c8f4d033ccab7 to your computer and use it in GitHub Desktop.
Revisions
-
hn5092 created this gist
Apr 10, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,62 @@ package com.pajk.bigdata.flink.utils; import org.apache.hadoop.hbase.util.Bytes; import org.testng.annotations.Test; import org.testng.collections.Lists; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.List; /** * Created by imad on 10/04/2017. */ public class MyTriggerTest { @Test public void testRead() throws IOException { List<String> processed = Lists.newArrayList(); List<String> lists = Files.readAllLines(Paths.get("/xym/sync/DATA0")); lists.stream().forEach( line -> { String[] split = line.split("\\001"); long x = Bytes.toLong(split[split.length - 1].getBytes()); split[split.length-1]= x +""; processed.add(String.join("\001",split)); } ); Files.write(Paths.get("/xym/sync/DATA2"),processed); } public static byte[] hex2Bytes1(String src){ byte[] res = new byte[src.length()/2]; char[] chs = src.toCharArray(); int[] b = new int[2]; for(int i=0,c=0; i<chs.length; i+=2,c++){ for(int j=0; j<2; j++){ if(chs[i+j]>='0' && chs[i+j]<='9'){ b[j] = (chs[i+j]-'0'); }else if(chs[i+j]>='A' && chs[i+j]<='F'){ b[j] = (chs[i+j]-'A'+10); }else if(chs[i+j]>='a' && chs[i+j]<='f'){ b[j] = (chs[i+j]-'a'+10); } } b[0] = (b[0]&0x0f)<<4; b[1] = (b[1]&0x0f); res[c] = (byte) (b[0] | b[1]); } return res; } }