小编use*_*718的帖子

在C++中的特定路径中写入文件

我有这个代码成功写入一个文件:

    ofstream outfile (path);
    outfile.write(buffer,size);
    outfile.flush();
    outfile.close();
Run Code Online (Sandbox Code Playgroud)

缓冲区和大小在其余代码中都可以.如何将文件放在特定路径中?

c++ file filepath

9
推荐指数
2
解决办法
8万
查看次数

使用Java的LDAP over SSL

以下代码工作正常:

public static void main(String[] args) {
    String userName = "admin";
    String password = "s3cret";
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://192.168.10.45:389/dc=softwaredev,dc=local");
    //env.put(Context.SECURITY_PROTOCOL, "ssl");
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    env.put(Context.SECURITY_PRINCIPAL, new String("softwaredev" + "\\" + userName));
    env.put(Context.SECURITY_CREDENTIALS, password);

    DirContext ctx = null;
    NamingEnumeration results = null;
    try {
        ctx = new InitialDirContext(env);
        SearchControls controls = new SearchControls();
        controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
        results = ctx.search("", "(objectclass=person)", controls);
        while (results.hasMore()) {
            SearchResult searchResult = (SearchResult) results.next();
            Attributes attributes = searchResult.getAttributes();
            System.out.println(" Person Common Name = " …
Run Code Online (Sandbox Code Playgroud)

java ssl ldap

6
推荐指数
1
解决办法
2万
查看次数

使用Github api进行协议违规

我从Github获取数据用于我的应用程序.前两个OAuth步骤没问题,但在第三个中我得到以下错误:"服务器提交了协议违规.Section = ResponseStatusLine ERROR"这是我的代码:

protected String WebRequest(string url)
    {
        url += (String.IsNullOrEmpty(new Uri(url).Query) ? "?" : "&") + "access_token=" + _accessToken;
        HttpWebRequest webRequest = System.Net.WebRequest.Create(url) as HttpWebRequest;
        webRequest.Method = "GET";
        webRequest.ServicePoint.Expect100Continue = false;
        try
        {
            using (StreamReader responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream()))
                return responseReader.ReadToEnd();
        }
        catch
        {
            return String.Empty;
        }
    }
Run Code Online (Sandbox Code Playgroud)

使用StreamReader对象后程序进入异常,返回错误.如果我遵循这些说明服务器提交了协议违规.Section = ResponseStatusLine ERROR,错误变为"403 forbidden".当Github使用api V2时,与现在不同,这段代码没有问题.因此,不能是.NET限制,而是与Github服务器连接的东西.有什么建议?

.net c# api github

5
推荐指数
1
解决办法
1312
查看次数

错误:需要在环境或系统属性LDAP和JNDI中指定类名

这是我的代码:

     public class TestConnection {

public static void main(String[] args) {
    String password = "s3cret";
    Map<String, String> env = new HashMap<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://localhost:389/dc=userdev,dc=local");
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    //env.put(Context.SECURITY_PRINCIPAL, "uid="+ username +"cn=users"); // replace with user DN
    env.put(Context.SECURITY_PRINCIPAL, "cn=dcmanager,cn=users,dc=userdev,dc=local"); // replace with user DN
    env.put(Context.SECURITY_CREDENTIALS, password);

    DirContext ctx = null;
    try {
       ctx = new InitialDirContext();
    } catch (NamingException e) {
       // handle
    }
    try {
       SearchControls controls = new SearchControls();
       controls.setSearchScope( SearchControls.SUBTREE_SCOPE);
       ctx.search( "", "(objectclass=person)", controls);
       // no need …
Run Code Online (Sandbox Code Playgroud)

java jndi ldap

5
推荐指数
1
解决办法
5万
查看次数

如何使用 LinkedList&lt;String&gt; 内联将值传递给函数?

我有一个简单的功能,如:

private void function(LinkedList<String> a, LinkedList<String> b)
Run Code Online (Sandbox Code Playgroud)

我们已经知道,如果这些参数只是字符串,那么内联传递值会很容易,例如:

function("aaa", "bbb")
Run Code Online (Sandbox Code Playgroud)

但是有没有办法通过内联 LinkedList ?

我试过:

function(["A", "B", "C"], ["A", "B"])
Run Code Online (Sandbox Code Playgroud)

但它不起作用。

java linked-list

5
推荐指数
1
解决办法
87
查看次数

是否有可能实时监控linux下的所有系统调用?

例如,在linux-machine中有很多进程.每个人都可以使用系统调用,但通常很少使用.那么,有一种工具或方式可以显示何时使用系统调用以及哪个进程相关联?

c linux system-calls linux-kernel

3
推荐指数
1
解决办法
1045
查看次数

C#使用SHA1将字符串哈希到字节数组中

我正在使用SHA1来加密一些像密码这样的值.这是我的代码:

String passwd = Membership.GeneratePassword(10, 2);
SHA1 sha = new SHA1CryptoServiceProvider();
byte [] password = sha.ComputeHash(passwd);
Run Code Online (Sandbox Code Playgroud)

但VS返回错误,因为passwd是一个字符串.我必须将密码存储在字节数组中,那么有没有办法解决这个问题?

c# encryption sha1

3
推荐指数
1
解决办法
2万
查看次数

一个在C中停止另一个的线程

我有2个帖子.我的目标是第一个终止自己的执行,必须停止另一个线程.可能吗?

我有这个代码:

#include <stdio.h>
#include <pthread.h>
#include <sys/types.h>

void* start1(void* arg)
{
  printf("I'm just born 1\n");
  int i = 0;
  for (i = 0;i < 100;i++)
  {
    printf("Thread 1\n");
  }
  printf("I'm dead 1\n");
  pthread_exit(0);
}

void* start2(void* arg)
{
  printf("I'm just born 2\n");
  int i = 0;
  for (i = 0;i < 1000;i++)
  {
    printf("Thread 2\n");
  }
  printf("I'm dead 2\n");
  pthread_exit(0);
}

void* function()
{
  int k = 0;
  int i = 0;
  for (i = 0;i < 50;i++)
  { …
Run Code Online (Sandbox Code Playgroud)

c c++ pthreads

2
推荐指数
1
解决办法
1768
查看次数

Java Bitset初始化

我正在为我的程序使用BitSet类.我需要一个内联声明,如:

BitSet bits1 = new BitSet(); //standard declaration
bits1.set(0,2);
bits1.set(4,6);
System.out.println(bits1); //110011

BitSet bits2 = BitSet.valueOf(new long[] {1,1,0,0,1,1}); //inline
System.out.println(bits2);
Run Code Online (Sandbox Code Playgroud)

有了这个代码,我试图复制相同的位集合是在BITS1,在BITS2.问题如下:打印和值不同.我设置的BitSet是110011.第一个打印出{0,1,4,5}并且它是正确的,因为这是用索引打印BitSet的"好方法",第二个打印出{0,64, 256,320}.你可以看到第二个是错的.我很确定内联初始化是错误的,但我无法弄清楚如何解决这个问题.

java initialization bitset

1
推荐指数
1
解决办法
1181
查看次数

CGI应用程序是否有更好的编程语言?

我知道我可以用多种语言编写CGI,最多的是C和Perl.但为什么我必须在Perl或C中编写它?有什么区别,什么是(最终)最好和最安全的解决方案?

c perl cgi

0
推荐指数
1
解决办法
793
查看次数

标签 统计

java ×4

c ×3

c# ×2

c++ ×2

ldap ×2

.net ×1

api ×1

bitset ×1

cgi ×1

encryption ×1

file ×1

filepath ×1

github ×1

initialization ×1

jndi ×1

linked-list ×1

linux ×1

linux-kernel ×1

perl ×1

pthreads ×1

sha1 ×1

ssl ×1

system-calls ×1