标签: bytearray

java null指针异常

我得到java.lang.NullPointerExceptionwhile ((len = in.read(buf , 0 , buf.length)) >= 0)在下面的方法:

public void copy(String  src, File dst) throws IOException {

  InputStream in = getClass().getResourceAsStream(src); 
        OutputStream out = new FileOutputStream(dst);

        byte[] buf = new byte[1012];
        int len;
        while ((len = in.read(buf , 0 , buf.length)) >= 0) {
            out.write(buf, 0, len);
            buf = null;
        }
        in.close();
        out.close();
    }
Run Code Online (Sandbox Code Playgroud)

我没有得到它.如果我得到解决方案,我会很感激.谢谢你提前.......

java bytearray stream

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

Char-array到int

我有一个阵列 char input[11] = {'0','2','7', '-','1','1','2', ,'0','0','9','5'};

如何将输入[0,1,2]转换为int one = 27输入[3,4,5,6] int two = -112并输入[7,8,9,10]为int three = 95

是的,JNK

c c++ int bytearray

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

C#转换为字节数组

如何将此VBNet代码转换为C#?(ByteToImage是一个用户定义的函数使用,以字节数组转换成位图.

Dim Bytes() As Byte = CType(SQLreader("ImageList"), Byte())
picStudent.Image = jwImage.ByteToImage(Bytes)
Run Code Online (Sandbox Code Playgroud)

我试过了

byte[] Bytes = Convert.ToByte(SQLreader("ImageList")); // Error Here
picStudent.Image = jwImage.ByteToImage(Bytes);
Run Code Online (Sandbox Code Playgroud)

但它会产生错误说: Cannot implicitly convert type 'byte' to 'byte[]'

我正在做的基本上是将图像从数据库转换为字节数组并将其显示在图片框上.

c# bytearray

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

无法将sql连接字符串转换为byte []

我试图转换包含普通字符和'_',';'和'='的sqlstring,当我尝试这样做时:

Byte[] byt = Convert.FromBase64String(value);
Run Code Online (Sandbox Code Playgroud)

我收到此错误消息

An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll

Additional information: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
Run Code Online (Sandbox Code Playgroud)

Additonal: - 我用它来加密sqlstring -my解密,它使用同样的功能工作正常,但在尝试转换回加密时失败

c# sql encryption cryptography bytearray

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

将两个字节数组合并为一个字节数组的最有效方法是什么?

我有两个字节数组.我想将这两个字节数组合并为一个字节数组.

通常,我只是创建一个新的字节数组,其长度为= byte array#1 + byte array#2.然后将字节数组#1和#2复制到新的字节数组.

有没有一种更有效的方法来使用VB.NET和.NET 4合并两个字节数组?

.net vb.net merge bytearray .net-4.0

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

从byte []到String的精确转换

数组byte []包含照片的完美逐字节副本,当我尝试将byte []转换为String并使用它写入文件时,它会失败.

我需要转换为字符串以便稍后通过套接字发送它.

我的每个连接的处理程序都有一个Socket(sock),PrintWriter(out)和BufferedReader(in),然后我将Socket与PrintWriter和BufferedReader相关联.有了这个,我发送和接收字符串out.println和in.readLine.

我怎样才能解决这个问题?

测试代码:

// getPhoto() returns byte[]
String photo = new String(getPhoto());

// Create file
DataOutputStream os = new DataOutputStream(new FileOutputStream("out1.jpg"));
// This makes imperfect copy of the photo
os.writeBytes(photo);

//This works perfectly basically it copies the image through byte[]
//os.write(getPhoto());

// Close the output stream
os.close();
Run Code Online (Sandbox Code Playgroud)

java string bytearray file

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

如何从文件读取字节到byte []数组?

我正在编写一个Java程序,它使用RSA加密给定的文本,并将加密的字节(byte []数组)保存在.txt文件中.有一个单独的解密程序读取这些字节.现在我想将相同的字节读入解密程序的byte []中.如何使用Java完成?

BufferedReader brip = new BufferedReader(new FileReader("encrypted.txt"));
Strings CurrentLine = brip.readLine();
byte[] b = sCurrentLine.getBytes();
Run Code Online (Sandbox Code Playgroud)

这就是我从文件中读取数据的方式.但这是错误的,因为它将sCurrentLine变量中的字节转换为再次字节.

java byte bytearray file

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

更快的代码从字节数组中删除第一个元素

所以我有一个字节数组,我需要从中删除前5个元素.无论如何,我在网上看了一下,找不到任何适合我想要的东西.所以我做了这个,它本质上是非常缓慢的,无法使用.

        private byte[] fR(byte[] tb)
        {
            string b = "";
            byte[] m = new byte[tb.Length - 5];
            for (int a = 5; a < tb.Length; a++)
            {
                b = b + " " + tb.GetValue(a);
            }
            b = b.Remove(0, 1);
            string[] rd = Regex.Split(b, " ");
            for (int c = 0; c < rd.Length; c++)
            {
                byte curr = Convert.ToByte(rd[c]);
                m.SetValue(curr, c);
            }
            return m;
         }
Run Code Online (Sandbox Code Playgroud)

我要问的是,是否有办法让这更快/更好.或者我可以从字节数组中删除前5个元素的另一种方法.

c# algorithm bytearray

-4
推荐指数
2
解决办法
6385
查看次数

标签 统计

bytearray ×8

c# ×3

java ×3

file ×2

.net ×1

.net-4.0 ×1

algorithm ×1

byte ×1

c ×1

c++ ×1

cryptography ×1

encryption ×1

int ×1

merge ×1

sql ×1

stream ×1

string ×1

vb.net ×1