All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jgroups.tests.HexToBinary Maven / Gradle / Ivy

Go to download

This artifact provides a single jar that contains all classes required to use remote EJB and JMS, including all dependencies. It is intended for use by those not using maven, maven users should just import the EJB and JMS BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up with different versions on classes on the class path).

The newest version!
package org.jgroups.tests;

import org.jgroups.util.Util;

import java.io.*;
import java.util.stream.Stream;

/**
 * @author Bela Ban
 * @since  4.0.16
 */
public class HexToBinary {


    public static void main(String[] args) throws Exception {
        if(args.length != 2) {
            System.err.printf("%s  \n", HexToBinary.class.getSimpleName());
            return;
        }

        File input_file=new File(args[0]);
        File output_file=new File(args[1]);

        if(!input_file.exists())
            throw new FileNotFoundException(input_file.toString());
        if (!output_file.exists())
            output_file.createNewFile();
        FileWriter fw = new FileWriter(output_file.getAbsoluteFile());
        BufferedWriter bw = new BufferedWriter(fw);

        BufferedReader br=null;
        try {
            br = new BufferedReader(new FileReader(input_file));

            Stream lines=br.lines();
            lines.forEach(sCurrentLine -> {
                if(sCurrentLine != null && !sCurrentLine.isEmpty()) {
                    String bits=Util.hexToBin(sCurrentLine);
                    try {
                        bw.write(bits);
                    }
                    catch(IOException e) {
                        e.printStackTrace();
                    }
                }
            });

           // while ((sCurrentLine = br.readLine(true)) != null) {
             //   bits = Util.hexToBin(sCurrentLine);
               // bw.write(bits);
            //}


            bw.close();
            System.out.println("done....");

        }
        catch (Throwable e) {
            e.printStackTrace();
        }
        finally {
            try {
                if (br != null)br.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy