English 中文(简体)
Byte "0" written as Byte "32”, with Java ́s OutputStream.write() function
原标题:Byte "0" written as Byte "32" with Java´s OutputStream.write() function

在我的法典中(Met方法中的HttpServlet),我需要用能够从0到255的字面书写。 我在抽调中检查了结果3.1的数值。 然而,在外部档案中,它被写成空白处,在我试图读到时,它具有“32”的附带价值。 我只剩下零号,因为其余部分工作是完美的。 任何想法?

res.setContentType("image/gif");
res.setHeader("Content-Disposition","attachment;filename=myFile.js");
OutputStream os = res.getOutputStream();
byte[] result=encrypt(req.getParameter("original")); // Here result has values [64,0,81,80]
os.write(result,0,result.length);

我从外部的 Java文中取回了价值:

var whatever = data[1].charCodeAt(0); // whatever has value 32

我在 Java文方案中也看到了类似的问题,并确定了这一问题,包括这一在撰写前有权提出:

for (var i=0; i<result.length; i++) {
    result[i] = String.fromCharCode(result[i]); }

I have do some tests and works for Javascript. What would be the equivalent in Java?

Thanks

最佳回答

阅读二元数据已在Stackoverflow中作了答复:。 我如何将双元数据读到 Java字体内的一个星体?

内容类型更好的是<条码> 申请/使用/代码>,没有内容处理标题。

问题回答

32 是ASCII对空白空间的价值。 正因为如此,你在32个空白处被 。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签