Converting a class - InputStream to a String

Hi. Very new to Java. I have the following class
import java.io.*;
class ShiftedInputStream extends InputStream
    ShiftedInputStream(InputStream source)
        source_ = source;
    public int read() throws IOException
        int bite = source_.read();
        if (bite != -1)
            bite >>>= 1;
        return bite;
    private InputStream source_;}
Currently being called as follows;
BufferedReader br = new BufferedReader( new InputStreamReader(new ShiftedInputStream(new FileInputStream( "/home/rich/cosworth/Logs/passwords.txt" )), "ASCII"));Rather than passing a file in (passwords.txt) I want to pass in a String. The problem I have is that I don't know the best way to do it. Do I
1) change the class ShiftedInputStream to accept a String, and if so how do I read a String bite by bite.
2) convert the String I want to pass in to an InputStream
3) something else completely.
Thanks for any help

I din get it still... But if ur talkin abt typecasting
Byte to string
string s = System.Text.Encoding.UTF8.GetString(bytes);String to byte
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(s);

Similar Messages

  • Cannot convert type class java.lang.String to class oracle.jbo.domain.Clob

    Cannot convert type class java.lang.String to class oracle.jbo.domain.ClobDomain.
    Using ADF Business Components I have a JSFF page fragment with an ADF form based on a table with has a column of type CLOB. The data is retrieved from the database and displayed correctly but when any field is changed and submitted the above error occurs. I have just used the drag and drop technique to create the ADF form with a submit button, am I missing a step?
    I am using the production release of Jdeveloper11G

    Reproduced and filed bug# 7487124
    The workaround is to add a custom converter class to your ViewController project like this
    package oow2008.view;
    import javax.faces.application.FacesMessage;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.convert.Converter;
    import javax.faces.convert.ConverterException;
    import oracle.jbo.domain.ClobDomain;
    import oracle.jbo.domain.DataCreationException;
    public class ClobConverter implements Converter {
         public Object getAsObject(FacesContext facesContext,
                                   UIComponent uIComponent,
                                   String string) {
           try {
             return string != null ? new ClobDomain(string) : null;
           } catch (DataCreationException dce) {
             dce.setAppendCodes(false);
             FacesMessage fm =
               new FacesMessage(FacesMessage.SEVERITY_ERROR,
                                "Invalid Clob Value",
                                dce.getMessage());
             throw new ConverterException(fm);
         public String getAsString(FacesContext facesContext,
                                   UIComponent uIComponent,
                                   Object object) {
           return object != null ?
                  object.toString() :
                  null;
    }then to register the converter in faces-config.xml like this
    <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee">
      <application>
        <default-render-kit-id>oracle.adf.rich</default-render-kit-id>
      </application>
      <converter>
        <converter-id>clobConverter</converter-id>
        <converter-class>oow2008.view.ClobConverter</converter-class>
      </converter>
    </faces-config>then reference this converter in the field for the ClobDomain value like this
              <af:inputText value="#{bindings.Description.inputValue}"
                            label="#{bindings.Description.hints.label}"
                            required="#{bindings.Description.hints.mandatory}"
                            columns="40"
                            maximumLength="#{bindings.Description.hints.precision}"
                            shortDesc="#{bindings.Description.hints.tooltip}"
                            wrap="soft" rows="10">
                <f:validator binding="#{bindings.Description.validator}"/>
                <f:converter converterId="clobConverter"/>
              </af:inputText>

  • Convert to class instance into string/binary

    Hello friends,
    is there a utility to convert a class instance into string or binary.
    regards
    kaushik

    Take a look at CL_ABAP_STRING_UTILITIES
    Best!
    Jim

  • Converting a class file to a dll

    Hai please help me..
    I am trying to convert my .class file to a .dll file.
    This is my java code:
    public class DateFunctions {
         public int getTimeInSeconds(int i){
              return i;
         public int addNumbers(int i, int j) {
              return (i+j);
         public static void main(String[] args) {
              DateFunctions df=new DateFunctions();
              df.getTimeInSeconds(
    Created class file DateFunctions.class.
    Created jar DateFunctions.jar using:
    jar cvf DateFunctions.jar DateFunctions.class
    Generated dll file using bimp tool like this (Visual J# .NET tool):
    jbimp DateFunctions.jar /t:library
    I got the file: DateFunctions.dll
    Now loaded this dll into my code (say, TSL code in WinRunner) using load_dll("DateFunctions.dll");
    When I try to access the method like:
    j=getTimeInSeconds(int i);
    I am getting the error RPC error.
    Note: DLL is loading fine. but while accessing the functions I am getting the RPC error..
    What could be the reason..?
    Please help...?
    Thanks,
    Satish

    Your answer lies in the documentation for WinRunner and whatever else is calling the DLL.
    Certainly Java JNI has requirements for DLLs called from Java: They have to be C++ bindings that use the native header that Java generates, right?
    So now you need to look at the requirements for your WinRunner and make sure that the program translating your .class file to a DLL does it in a such a way that the bindings WinRunner expects are indeed there.
    But none of that has anything to do with Java. If your Java class compiles and tests successfully, then your questions about Java are satisfied. You have to figure out what WinRunner needs and what's missing from what you supplied.
    %

  • Error: could not be converted to [class java.lang.Class].

    I am newbie to JDeveloper (10.1.2) on winxp and i was trying to setup the example from the following url http://radio.weblogs.com/0129487/2003/09/19.html
    It is a how to on "Executing Toplink Queries using JavaBean DataControl "
    Any help would be greatly appreciated.
    Near the bottom on step "In StrutsPageFlow diagram, select allEmpsDA Data Action, right mouse and chooe Run" i get a the following runtime errors:
    Validation Error
    You must correct the following error(s) before proceeding:
    JBO-29000: Unexpected exception caught: oracle.jbo.JboException, msg=JBO-29000: Unexpected exception caught: oracle.toplink.exceptions.ConversionException, msg= Exception Description: The object [mypackage.Employees], of class [class java.lang.String], could not be converted to [class java.lang.Class]. Please ensure that the class [class java.lang.Class] is on the CLASSPATH. You may need to use alternate API passing in the appropriate class loader as required, or setting it on the default ConversionManager Internal Exception: java.lang.ClassNotFoundException: mypackage.Employees
    JBO-29000: Unexpected exception caught: oracle.toplink.exceptions.ConversionException, msg= Exception Description: The object [mypackage.Employees], of class [class java.lang.String], could not be converted to [class java.lang.Class]. Please ensure that the class [class java.lang.Class] is on the CLASSPATH. You may need to use alternate API passing in the appropriate class loader as required, or setting it on the default ConversionManager Internal Exception: java.lang.ClassNotFoundException: mypackage.Employees
    Exception Description: The object [mypackage.Employees], of class [class java.lang.String], could not be converted to [class java.lang.Class]. Please ensure that the class [class java.lang.Class] is on the CLASSPATH. You may need to use alternate API passing in the appropriate class loader as required, or setting it on the default ConversionManager Internal Exception: java.lang.ClassNotFoundException: mypackage.Employees

    This error is happening on a read.
    Here is the mapping descriptor:
    <database-mapping>
    <attribute-name>SuppItemCollection</attribute-name>
    <read-only>false</read-only>
    <reference-class>package.SuppItem</reference-class>
    <is-private-owned>false</is-private-owned>
    <uses-batch-reading>false</uses-batch-reading>
    <indirection-policy>
    <mapping-indirection-policy>
    <type>oracle.toplink.internal.indirection.NoIndirectionPolicy</type>
    </mapping-indirection-policy>
    </indirection-policy>
    <container-policy>
    <mapping-container-policy>
    <container-class>java.util.Vector</container-class>
    <type>oracle.toplink.internal.queryframework.ListContainerPolicy</type>
    </mapping-container-policy>
    </container-policy>
    <source-key-fields>
    <field>SUPP.REQ_NUM</field>
    </source-key-fields>
    <target-foreign-key-fields>
    <field>SUPP_ITEM.REQ_NUM</field>
    </target-foreign-key-fields>
    <type>oracle.toplink.mappings.OneToManyMapping</type>
    </database-mapping>
    Object model has a Supp class that has a collection of SuppItem(s). I was allowing the Mapping Workbench to create the Java Source. I'm not to fond of that, but I thought it would be easiest to get things going.
    The datamodel is similiar to the class model.
    Thanks for the help,
    Mike

  • InputStream from a String?

    Hi all,
    does anybody know how you would go about getting a java.io.InputStream from a string object? I know you can create a StringReader from a string, but the StringBufferInputStream is depreciated. I want to parse an xml String with the DocumentBuilder class, but it only takes an InputStream object, not a Reader object.
    any suggestions?
    thanks,
    J

    Adding to Mr. Sampieri's explanation:
    The encoding is specified in the initial processing instruction of the XML. If absent, the default encoding is UTF-8. (The default encoding of Java depends on the locale, so it's better to specify the correct encoding when writing your program.)
    Check if the names of the XML encodings are different from the names of the Java encodings (charsets).
      <?xml version="1.0" encoding="ISO8859-1" ?>

  • Converting hexadecimal XML data to a string

    Hello!
    Until now I generated XML data with the FM 'SDIXML_DOM_TO_XML'.
    After that I did a loop over the xml_as_table in which I was casting each line of that table to a string.
    ASSIGN <line> TO <line_c> CASTING.
    After the inftroduction of unicode in our system I get a error:
    In the current program an error occured when setting the field symbol <LINE_C> with ASSIGN or ASSIGNING (maybe in combination with the CASTING addition).
    When converting the base entry of the field symbol <LINE_C> (number in base table: 32776), it was found that the target type requests a memory alignment of 2
    What does it mean? Does somebody have a solution.
    I need this function for sending this XML data as string over a simple old CPIC connection.
    Best regards
    Martin

    Hello Martin
    Perhaps my sample report ZUS_SDN_XML_XSTRING_TO_STRING provides a solution for your problem.
    *& Report  ZUS_SDN_XML_XSTRING_TO_STRING
    *& Thread: Converting hexadecimal XML data to a string
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1029652"></a>
    REPORT  zus_sdn_xml_xstring_to_string.
    *-- data
    *-- read the XML document from the frontend machine
    TYPES: BEGIN OF xml_line,
            data(256) TYPE x,
          END OF xml_line.
    DATA: xml_table TYPE TABLE OF xml_line.
    DATA: go_xml_doc       TYPE REF TO cl_xml_document,
          gd_xml_string    TYPE string,
          gd_rc            TYPE i.
    PARAMETERS:
      p_file  TYPE localfile  DEFAULT 'C:payload_idoc.xml'.
    START-OF-SELECTION.
      CREATE OBJECT go_xml_doc.
      " Load XML file from PC and get XML itab
      CALL METHOD go_xml_doc->import_from_file
        EXPORTING
          filename = p_file
        RECEIVING
          retcode  = gd_rc.
      CALL METHOD go_xml_doc->get_as_table
        IMPORTING
          table   = xml_table
    *      size    =
    *      retcode =
    " NOTE: simulate creation of XML itab
      go_xml_doc->display( ).
      create object go_xml_doc.
      CALL METHOD go_xml_doc->parse_table
        EXPORTING
          table   = xml_table
    *      size    = 0
        receiving
          retcode = gd_rc.
      CALL METHOD go_xml_doc->render_2_string
    *    EXPORTING
    *      pretty_print = 'X'
        IMPORTING
          retcode      = gd_rc
          stream       = gd_xml_string
    *      size         =
      write: / gd_xml_string.
    END-OF-SELECTION.
    Regards
      Uwe

  • How to convert the class in the one package to same class in the other pack

    How to convert the class in the one package to same class in the other package
    example:
    BeanDTO.java
    package cho3.hello.bean;
    public class BeanDTO {
    private String name;
    private int age;
    * @return
    public int getAge() {
         return age;
    * @return
    public String getName() {
         return name;
    * @param i
    public void setAge(int i) {
         age = i;
    * @param string
    public void setName(String string) {
         name = string;
    BeanDTO.java in other package
    package ch03.hello;
    public class BeanDTO {
    private String name;
    private int age;
    * @return
    public int getAge() {
         return age;
    * @return
    public String getName() {
         return name;
    * @param i
    public void setAge(int i) {
         age = i;
    * @param string
    public void setName(String string) {
         name = string;
    My converter lass lokks like
    public class BeanUtilTest {
         public static void main(String[] args) {
              try
                   ch03.hello.BeanDTO bean=new ch03.hello.BeanDTO();
              bean.setAge(10);
              bean.setName("mahesh");
              cho3.hello.bean.BeanDTO beanDto=new cho3.hello.bean.BeanDTO();
              ClassConverter classconv=new ClassConverter();
              //classconv.
              System.out.println("hi "+beanDto.getClass().toString());
              System.out.println("hi helli "+bean.toString()+" "+bean.getAge()+" "+bean.getName()+" "+bean.getClass());
              Object b=classconv.convert(beanDto.getClass(),(Object)bean);
              System.out.println(b.toString());
              beanDto= (cho3.hello.bean.BeanDTO)b;
              System.out.println(" "+beanDto.getAge()+" "+beanDto.getName() );
              }catch(Exception e)
                   e.printStackTrace();
    But its giving class cast exception. Please help on this..

    Do you mean "two different layers" as in separate JVMs or "two different layers" as in functional areas running within the same JVM.
    In either case, if the first class is actually semantically and functionally the same as the second (and they are always intended to be the same) then import and and use the first class in place of the second. That's beyond any question of how to get the data of the first into the second if and when you need to.
    Once you make the breakthrough and use one class instead of two I'd guess that almost solves your problem. But if you want to describe your architecture a little that would help others pin down want you're trying to do.

  • Converter-for-class

    Is converter-for-class or any other "-for-class" attributes required to match against subclasses of the specified class, or just the class itself?
    It you specify converter-for-class as Object, is the converter required to apply to every subclass of Object (i.e. every class), or just to those properties with a runtime value of exactly Object?
    Thanks.

    Hello BalusC,
    thanks for reply. I'm definitely use JSF RI 1.2_13.
    The problem is, that the converter-method public String getAsString( FacesContext p_ctx, UIComponent p_comp, Object p_value ) is never called.
    But the other method public Object getAsObject( FacesContext p_ctx, UIComponent p_comp, String p_value ) is called.
    BalusC, which JSF implementation do you use?
    regards, Joerg

  • Strange problem when tried to convert HelloWorld.class..

    Hi friends..
    i've downloaded the Java Card SDK 2.2.1, and i tried to compile HelloWorld application that shipped with its distribution..
    i found strange problem when i tried to convert HelloWorld.class into .CAP, etc.. :(
    I use Windows XP, assume that i've set the Environment Variables needed
    i've compiled the HelloWorld.java into HelloWorld.class..
    the package of of HelloWorld is : com.sun.javacard.samples.HelloWorld;
    and i use this config file :
    -out EXP JCA CAP
    -exportpath .
    -applet  0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x1:0x1 com.sun.javacard.samples.HelloWorld.HelloWorld
    com.sun.javacard.samples.HelloWorld
    0xa0:0x0:0x0:0x0:0x62:0x3:0x1:0xc:0x1 1.0and then i tried to run converter script in the Console :
    *C:\java_card_kit-2_2_1\samples>converter -config com\sun\javacard\samples\HelloWorld\HelloWorld.opt*
    *error: file com\sun\javacard\samples\HelloWorld\HelloWorld.opt could not be found*
    Usage:  converter  <options>  package_name  package_aid  major_version.minor_ve
    sion
    OR
    converter -config <filename>
                        use file for all options and parameters to converter
    Where options include:
            -classdir <the root directory of the class hierarchy>
                          set the root directory where the Converter
                          will look for classes
            -i            support the 32-bit integer type
            -exportpath  <list of directories>
                          list the root directories where the Converter
                          will look for export files
            -exportmap    use the token mapping from the pre-defined export
                          file of the package being converted. The converter
                          will look for the export file in the exportpath
            -applet <AID class_name>
                          set the applet AID and the class that defines the
                          install method for the applet
            -d <the root directory for output>
            -out  [CAP] [EXP] [JCA]
                          tell the Converter to output the CAP file,
                          and/or the JCA file, and/or the export file
            -V, -version  print the Converter version string
            -v, -verbose  enable verbose output
            -help         print out this message
            -nowarn       instruct the Converter to not report warning messages
            -mask         indicate this package is for mask, so restrictions on
                          native methods are relaxed
            -debug        enable generation of debugging information
            -nobanner     suppress all standard output messages
            -noverify     turn off verification. Verification is defaultPlease help me regarding this, because i'm new in this field..
    Thanks in advance..

    Thanks safarmer for your reply..
    i tried this :
    C:\java_card_kit-2_2_1\samples>javac -target 1.3 -source 1.1 -g -classpath .\cla
    sses;..\lib\api.jar;..\lib\installer.jar src\com\sun\javacard\samples\HelloWorld
    \*.java
    javac: invalid source release: 1.1
    Usage: javac <options> <source files>
    use -help for a list of possible options
    C:\java_card_kit-2_2_1\samples>javac -target 1.3 -source 1.2 -g -classpath .\cla
    sses;..\lib\api.jar;..\lib\installer.jar src\com\sun\javacard\samples\HelloWorld
    \*.java
    it seems that i can't specify the -source to 1.1, so i tried to use -source 1.2..
    after that, i tried to convert again, and i got this error :
    C:\java_card_kit-2_2_1\samples\src>converter -config com\sun\javacard\samples\He
    lloWorld\HelloWorld.opt
    Java Card 2.2.1 Class File Converter, Version 1.3
    Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to lic
    ense terms.
    error: com.sun.javacard.samples.HelloWorld.HelloWorld: unsupported class file fo
    rmat of version 47.0.
    conversion completed with 1 errors and 0 warnings.Please help me regarding this..
    Thanks in advance..

  • How do I convert an 8 bit serial data string I have received (say 01110101) into decimal format??

    I am having a hard time finding a function that will help me convert an 8 bit serial data string I have received (say 01110101) into decimal format.

    When you have your front panel displayed, you should a whole palette of controls that you can place on the front panel. If the palette is not displayed, thne just right click on your mouse and it should appear. The upper left most set of controls on the palette is Numeric. Go there and select Numeric Indicator to display a numeric output. On the diagram, you can also right click the output 1 and select Create>Indicator. The format string is %b (as in boy) for a binary string. As I said, this should be the value for the format string input. You can right click on the Scan From String and select Edit Scan String. This will bring up a dialog box in which you pick what you want to do (Scan Number) and how you want to do it (Scan Binary Integer
    It sounds like you really need to take a course in LabVIEW programming. There are are links here to NI classes and some on-line tutorials.

  • Thiz iz Urgent..........How to convert a .class file to a .java file

    Hi Everybody,
    I want to convert back a .class file (a compiled servlet) into .java (source code) file. How do I do it???
    Note using javap has not been of any help.
    Thanks in Advance
    Rajib

    Why don't you look at this thread:
    http://forums.java.sun.com/thread.jsp?forum=31&thread=143500
    If thats not enough, try searching all the forums for:
    "convert .java .class" That'll give yu a bunch of other threads...
    Sjur

  • How to convert java class file version without decompiling

    Hi,
    Oracle R12.1.3 i am having illegal access error while try to access the class file version Java 1.3 uses major version 47,So how to convert the class file version without using decompiling.
    Current java version is 1.6.0_07
    Is there any tool or API for converting class file version?
    Thanks,
    Selvapandian T

    Beside this I wonder where you get your error from since AFAIK 12c comes with java 1.6.
    Well wonder no more!
    OP isn't using Oracle 12c database.
    They are using Oracle R12.1.3 - which is the E- Business Suite.

  • How to convert a .class file?!!

    sorry guys,
    but I've a question in knowing the code of some file,
    I've zipped file, when I unzip it, it contains an html page with a .class files
    (passing parameters to applet)
    my problem is that I want to know the code of the .java file (which is not included)
    but the program is working well, coz I have the .class file,
    so, can I convert this .class file into a java file, so its java code could be readable (to understand it)
    thanks in Advance :)

    sorry man, but Can't u send me a specific link for downloading this "Java decomplier"
    coz I found my self in something called (jad decompiler) with lots of versions and this is confusing
    and Is that mean, that there's a decompiler which can convert the .class file into .java one?
    and thanks alot man.....u help me always!
    (I'm still begginner in java)

  • How to Convert a .class file into exe

    I need to convert a .class file to exe...
    If abybody know ...plz infrom me briefly....
    Thanx a lot

    I do not know.
    I come from china.
    [email protected]
    Is that suppose to be a racial joke?From his other post, I'm thinking he's actually serious. At first I thought it was just a troll, but even that email address looks correct (sina.com is a popular service in China and I don't expect an average troll to do 'research' like that).

Maybe you are looking for