2013年9月10日星期二

InputStream ... read (byte []) garbled


// 输入流
InputStream is = System.in;
try {
byte[] b =new byte[128];
is.read(b);
String str=new String(b);
System.out.println(str);

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}



This why garbled ?
------ Solution ---------------------------------------- ----
byte array that is a bunch of unused 0x00
------ Solution -------------------- ------------------------
you this way looks like a problem , if you read the contents of the length is less than 128 how to do ?

------ Solution ------------------------------------ --------

  
InputStream method used to make a string of what I read in the input string ?  

bother to paste the code, look at this post it http://cuisuqiang.iteye.com/blog/1434416

hope useful to you .
------ For reference only -------------------------------------- -

how to solve it , because I still use that string up to make a judgment whether it is a directory or a file, because the problem can not be judged . .
------ For reference only -------------------------------------- -
display problems
128 bytes.
front has a value , the latter has no value.
That behind the byte code 0000000000000000000000000000000000
this compilation , some computers are displayed as spaces , some computers display for your kind ? No.
------ For reference only ---------- -----------------------------

how it should read it ? I just want to give a space to put a string , and then read out the input string , why the empty also read out ? InputStream if only read byte [] ...
------ For reference only --------------------------- ------------


InputStream method used to make a string of what I read in the input string ?
------ For reference only -------------------------------------- -

    
InputStream method used to make a string of what I read in the input string ?          
  
bother to paste the code, look at this post it http://cuisuqiang.iteye.com/blog/1434416   
  
hope useful to you .  
useful, thank you.

没有评论:

发表评论