Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Convert byte to String

807599Apr 24 2007 — edited Apr 24 2007
Hi Guys,

I am trying to send a file over my network, started as one file, but now many, so i need to send the file name too, this is fine, as i've sent it as a Byte, but how do i convert that byte back to a string?

so far i've got this method...
strRemote = new BufferedInputStream(skt.getInputStream());
           byte[] downBuffer = new byte[2048];

           try {


              byte[] FileNameBytes  = new byte[ strRemote.read(downBuffer)];//read the filename
              FileName = new String(FileNameBytes); //this is where i'm stuck..

                strLocal = new FileOutputStream(
                        "C:/"+FileName.toString());//+FileName);
                } catch (FileNotFoundException ex ) {

                        System.out.println("File Name Error"+FileName);
                    System.exit(1);
                }
which just outputs File name Error and some mess.
anyideas?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 22 2007
Added on Apr 24 2007
4 comments
306 views