Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

convert a the value of a string buffer to input stream

Posted on 2004-09-13
6
Medium Priority
?
593 Views
Last Modified: 2011-10-03
I am trying to assign the value of String buffer to an inout stream. Could someone please help me with this?
0
Comment
Question by:g46905
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 92

Accepted Solution

by:
objects earned 200 total points
ID: 12050653
ByteArrayInpoutStream in = new ByteArrayInputStream(stringbuffer.toString().getBytes());
0
 

Author Comment

by:g46905
ID: 12050810
I tried the solution metioned above.For some reason,The starting letter is not being stored in the input stream.

For example:

String Buffer GS = "ABCDEFGHI"

when I read this into input stream

I see only "BCDEFGHI"

Can you please tell me why this is happening?

Thanks,
0
 
LVL 92

Expert Comment

by:objects
ID: 12050858
how are you reading from the stream?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:g46905
ID: 12050897
ByteArrayInputStream ba = new ByteArrayInputStream(gs.toString().getBytes());

I am passing this value as a parameter

processZipEntry(ba, size,segDelim,elemDel,fromDDD,toDDD,profileName);  

=======>>
public static void processZipEntry(InputStream f, int size,char segDel,char elemDel ,Date fromDDDt,Date toDDDt,String profName ) {
      
      Vector v = new Vector();
      StringBuffer sb = new StringBuffer();
          try {
                        
                  String stSlnValue = null;
                int sBegin = 0;
                size = size - HEADER_LENGTH;
          
              for (int i=0;i<size;i++){
   
                      char c = (char)f.read();
                     
                      sb.append(c);
                      if(sb.charAt(i) == segDel){
                            
                            System.out.println(" string value stSln :" + sb.toString().trim().substring(sBegin,i));
                                         
                         stSlnValue = sb.toString().trim().substring(sBegin,i) + elemDel + profName ;
                         
                         //System.out.println(" string value stSln :" + stSlnValue);
                         
                             if ((stSlnValue.toString().startsWith("GS*FA")) || (stSlnValue.toString().startsWith("ST")) || (stSlnValue.toString().startsWith("SLN"))){      
                             v.add(new String(stSlnValue));}
                                                         // if  
                             sBegin = i + 1;  
         
                                }//if condition
                         }   // for loop
     
        for (int j = 0; j< v.size(); j++) {
              
              System.out.println("Vector : " + v.elementAt(j));
              
              }
             
            } catch (Exception e) {System.out.println(" Error while reading file into the vector " );
                                     e.printStackTrace();} // end of try
  analizeLogs(v);
   sb = null;        
  v.clear();         

}// end of the method

Please let me know if you have any questions

Thanks for your help





0
 

Author Comment

by:g46905
ID: 12050911
I found whi it is not reading the first character. It is because of this particular statement.

System.out.println(" BA : " + ba.read());


I really appreciate all your help!!

Thanks again,
0
 
LVL 92

Expert Comment

by:objects
ID: 12050935
no worries :)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question