如何将BigInteger作为字节存储到文件中?

时间:2016-02-17 12:29:42

标签: java byte biginteger

如何将$ldap_server_url = "<<server_url>>"; ##GLOBAL CATALOG## $ldap_bind_dn = '<<bind dn>>'; $ldap_bind_dn_password = '<<bind password>>'; $ldapconn = ldap_connect($ldap_server_url); $ldap_bind = @ldap_bind($ldapconn, $ldap_bind_dn, $ldap_bind_dn_password); $attr = array('*'); $test = ldap_search($ldapconn, "dc=mydomain,dc=com", "(samaccountname=mydemouser)", $attr); $entry = ldap_first_entry($ldapconn, $test); $attrs = ldap_get_attributes($ldapconn, $entry); var_dump($attrs); 的字节值存储到文本文件中?示例代码:

BigInteger Ca

2 个答案:

答案 0 :(得分:1)

    BigInteger Ca = new BigInteger("0");
    byte[] array = Ca.toByteArray();
    OutputStream fos = new FileOutputStream("text.txt");
    ObjectOutputStream outputStream = new ObjectOutputStream(fos);
    outputStream.write(array);
    outputStream.close();
    fos.close();

答案 1 :(得分:0)

  File file = new File("Corrected.txt"); 
  Scanner sc = new Scanner(file); 
  FileWriter fw=new FileWriter("Correct.txt"); 
  BigInteger p = new BigInteger("0");
  while (sc.hasNextBigInteger())   
    {
        p = p.add(sc.nextBigInteger()); 
    }
    fw.write(p.toString());
    System.out.println(p); 
    fw.close();