Changing a String to a byte

Here is my problem. I read from the keyboard and I build a String. I need to take this String and change it to bytes so I can store it in an array of bytes. Please help
Thanks
Spoon

This any good to you?/*          The program gets info from the in-built ASCII files. binary characters
*          65 to 91 (01000001 to 01011011) and then writes them to a new file
*          called "Alphabet.txt" - (65 to 91 are the alphabet characters in upper case
import java.io.*;
class TextWrite2 {
        public static void main (String args[]) throws IOException {
            FileWriter text = new FileWriter("Alphabet.txt");
                 for (int i=97; i<123;i++) {
              text.write((char)i);
        text.close();
}

Similar Messages

  • How to put a String into a byte array

    How can i put a String into a byte array byte[]. So that i can send it to the serial port for output to an LCD display. Cheers David

    javadocs for String
    getBytes
    public byte[] getBytes()
    Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array.
    Returns:
    The resultant byte arraySince:
    JDK1.1

  • Help with Sample on Converting an XML string to a byte stream

    Hello All,<br /><br />I am sure this is something simple, but I am just not figuring it out right now.<br /><br />I am following the sample - "Converting an XML string to a byte stream" from the developer guide since I want to prepopulate just 1 field in my PDF form.<br /><br />How do I reference my form field within my servlet code properly??<br /><br />I have tried a few things now, my field is within a subform, so I thought it would be <root><subformName><fieldname>My data</fieldname></subformName></root>  I have also tried adding <page1> in there too.<br /><br />I am following everything else exactly as given in the sample code.<br /><br />I do have an embedded schema within the form and the field is bound.<br /><br />Thanks,<br />Jennifer

    Well, if you have a schema defined in the form, then the hierarchy of your data must match what is described in the schema. So, can't really tell you what it would look like, but just follow your schema.
    Chris
    Adobe Enterprise Developer Support

  • Number format changed to string in excel

    I want to store a table in excel file and in the table
    there is a number field that when I store it in the
    excel file ,I want it change to String format,
    because when it store it in the number format,
    it is a wrong number.
    thanks in advance

    "883923"
    Pretend you are explaining this to someone who has no idea what you are talking about (because we don't).
    Statements like "but therewas a problem" are next to meaningless because you didn't explain what the problem is.
    You don't give any useful information such as:
    * Version of JDeveloper/ADF
    * What technologies are you using (I guess ADF Faces, but I don't know)?
    * How did you try exporting to Excel?
    * What was the exact problem you had?
    I've already spent more time thinking about how to ask you questions to get to the real problem than you have formulating your question.
    John

  • Change a string to upcase

    Hi,
    How to change a string to all upcase.
    Thanks

    what about reading the api doc for String class?
    http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html

  • To change the string in Class Builder "New Method"

    HI friends,
    Im using the std program of "RFDOPR10"...(changed into my customised program as ZRFDOPR10).....
    Here i want to change the strings of Id_type eq 4 availble under the class builder "New Method".
    "id_ruler_string = '2.13.24.29|43|58|73|88|103|118|'" (for 24...i want to give 38.....then 45...)
    Pls help me how to change the std method function  for my z program...
    FYR:
    RFDOPR10 is the std program for tcode :"s_alr_87012178", Customer analysis.If u want to c the example report, in this tcode...give OI:1, Summ level:6, OI list:1 and Company CD:2 under Output control tab in selection screen with Company code.Now, u able to see the reports in the screen.There, after Customer number....I've to give some more spaces(length) for Sort field.
    Thanks & regards
    Sankar.

    No, but I suggest using a different editor which does allow a different text option and just pasting it in.

  • [svn:fx-trunk] 5915: Fixed compilation errors in the flex4test dev project by changing mx: String to fx:String .

    Revision: 5915<br />Author:   [email protected]<br />Date:     2009-04-03 14:17:15 -0700 (Fri, 03 Apr 2009)<br /><br />Log Message:<br />-----------<br />Fixed compilation errors in the flex4test dev project by changing <mx:String> to <fx:String>.<br /><br />QE Notes: None<br />Doc Notes: None<br />Bugs: None<br />Reviewer: N/A<br /><br />Modified Paths:<br />--------------<br />    flex/sdk/trunk/development/eclipse/flex/flex4test/src/NewEffects.mxml<br />    flex/sdk/trunk/development/eclipse/flex/flex4test/src/RemoveItemsTest.mxml<br />    flex/sdk/trunk/development/eclipse/flex/flex4test/src/SkinTest.mxml<br />    flex/sdk/trunk/development/eclipse/flex/flex4test/src/components/AnimationPropertiesForm. mxml<br />    flex/sdk/trunk/development/eclipse/flex/flex4test/src/flex4test.mxml

    Revision: 5915<br />Author:   [email protected]<br />Date:     2009-04-03 14:17:15 -0700 (Fri, 03 Apr 2009)<br /><br />Log Message:<br />-----------<br />Fixed compilation errors in the flex4test dev project by changing <mx:String> to <fx:String>.<br /><br />QE Notes: None<br />Doc Notes: None<br />Bugs: None<br />Reviewer: N/A<br /><br />Modified Paths:<br />--------------<br />    flex/sdk/trunk/development/eclipse/flex/flex4test/src/NewEffects.mxml<br />    flex/sdk/trunk/development/eclipse/flex/flex4test/src/RemoveItemsTest.mxml<br />    flex/sdk/trunk/development/eclipse/flex/flex4test/src/SkinTest.mxml<br />    flex/sdk/trunk/development/eclipse/flex/flex4test/src/components/AnimationPropertiesForm. mxml<br />    flex/sdk/trunk/development/eclipse/flex/flex4test/src/flex4test.mxml

  • Como obtener un array dbl de un string de 2 bytes

    como obtener un array dbl de un string de 2 bytes
    Adjuntos:
    dbl.png ‏37 KB

    Hola, un string de dos bytes no puede contener un double ya que el dbl es un número de 8 bytes.
    Acaso estás recibiendo alguna medicion de un conversor de 16 bits (un instrumento externo, un PIC o algo así)? Si es así el valor correspondiente en la unidad de medición (V, A, RPM...) debe calcularse con
        bits recibidos / 65536 * máximo de la medición
    Ejemplo: en un voltímetro de 100V / 16 bits, un valor de 8000 (bits) equivale a una medición de 12.207V
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • How do u change a string to a Date object??

    im using GregorianCalendar rite now to get dates..
    n i got 2 dates - one is current date, the other is another date(How do i say this?? hmm.... ok, my birthday).
    i had put them into "strings"
    but i gotta check which date came 1st.(current, or my birthday)
    i have found the method in Date.class, but before using the method, i gotta change the String to Date..
    this is where i got stuck..
    plz give me any info - codes, links, url, any things that helps..
    Thz people..

    SOrry for replying late..
    i did catch the exception, n print out
    catch(Exception e)
    System.out.println(e); --> this is where it print out the error msg.
    hmm, i tried to use the SimpleDateFormat class, as in in this link
    http://forum.java.sun.com/thread.jsp?forum=31&thread=345037
    the error shown up again, n with ("01/jan/2003");
    i wanted it to be in all numbers like ("01/01/2003");
    i think im confusing all of u now, coz i aint really good at explaining...
    but here parts of my codes..
    //edited code ---> using SimpleDateFOrmat
    Date d1 = new Date();
    Date d2 = new Date();
    DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    d1 = df.parse(appDate); //appDate="01/01/2003"
    d2 = df.parse(date); //date ="23/05/2003"
    }catch(ParseException a){System.out.println(a);}
    ++++++++++++++++++++++++++++++++++++++++++++++++
    //error msg
    error: java.text.ParseException: Unparseable date: "(01/jan/2003)";
    ++++++++++++++++++++++++++++++++++++++++++++++++
    //this is the orignal one
    Date d1 = new Date();
    Date d2 = new Date();
    DateFormat df = DateFormat.getDateInstance();
    d1 = df.parse(appDate); //appDate="01/01/2003"
    d2 = df.parse(date); //date ="23/05/2003"
    }catch(ParseException a){System.out.println(a);}
    ++++++++++++++++++++++++++++++++++++++++++++++++
    //error msg
    error: java.text.ParseException: Unparseable date: "(01/01/2003)";
    ++++++++++++++++++++++++++++++++++++++++++++++++
    Hope someone out there knows what actually gone wrong..
    n For those who reply or replied.. ThanK YOU!!!

  • Change a string parameter for different session

    Hi Gurus,
    I would like to find out how can I change a string parameter for an existing different session?
    In DBMS_SYSTEM package there are two functions :
    - SET_INT_PARAM_IN_SESSION
    - SET_BOOL_PARAM_IN_SESSION
    which change values of parameters, but not string ones :(
    Is it possible and if not, is there an alternative for changing STATISTICS_LEVEL for different session to ALL?
    Thank you in advance,
    Ela

    Hi,
    >>Once again: how to change a string parameter for a DIFFERENT session?
    Once again I will repeat if I was not clear before: You cannot to do this. Just directly using ALTER SESSION against the session.
    * SET_INT_PARAM_IN_SESSION: Sets[u] integer-type init.ora parameters in any session
    * SET_BOOL_PARAM_IN_SESSION: Sets boolean-type init.ora parameters in any session
    Cheers
    Legatti

  • How change a string in a CLOB field

    Hi all,
    I'm trying to explain my problem.
    I use an Asp procedure to load a html text in a Clob field.
    The simple algoritm is:
    - The first time that I visit the web address, I write in a field
    Desc_Webb_Attu --> CLOB
    - The second time that I visit the web address, I write in a field
    Desc_Webb_Attu_Temp --> CLOB
    - I see if there are differences between the first and the second visit, using this statment
    SELECT      dbms_lob.compare(Desc_Webb_Attu,Desc_Webb_Attu_Temp)
    From table
    The procedure run ok, but in the case of web addresses have a banner, counter or reloy, I'll have always that the web address will be modified :(
    I'm thinking to do in this way:
    If I can know where is the string of data (for example) I would change this string with blank, after to use the stament "compare".
    Do you know if is a statment or a procedure (I use Pl/sql) to resolve this?
    I hope that I have explained good
    Thank's for any suggestion
    Message was edited by:
    mosquito70

    for(i=0;arr!=null;i++)
    That's an infinite loop.OP: when you post code, use the code tags described here:
    http://forum.java.sun.com/help.jspa?sec=formatting
    The idea is that you put [code] at the start of your code and [/code]
    at the end. That way something like:
    [code]if(tagsUsed) {
        System.out.println("Output is nice.");
    }[/code]
    ends up displayed asif(tagsUsed) {
        System.out.println("Output is nice.");
    }This is especially important when arrays are used because otherwise
    bits of your your code "dissappear" (as you have found) and this causes
    confusion.

  • Putting a ( String into a byte[] to send through a datagram)

    I am making a program in java to send email in the form of an applet. I am not sure it is going to work but this is what I have so far:
    import java.awt.*;
    import java.io.*;
    import java.net.*;
    import javax.swing.event.*;
    public class EmailSender extends JFrame
    public void init()
    //user types in email address
    String recieveaddr = "";
    JTextField emailaddr = new JTextField(15, recieveaddr);
    //user types in his body of the email
    String message = "";
    JTextArea body = new JTextArea(50,50, body);
    //user presses submit button to send email
    JButton submit = new JButton("submit", emailaddr, body);
    public void run()
      try{
    /*I chose to use Datagram for my method to send the email.  I thought about Tcp.  I might change my mind.  I am not going to write down the source of what is supposed to go here.  What I just want to do here is take the message and the email address and send it.  I must know if there is a way to make a byte[] and write a String to it.  If I know this I would be able to send the message with Datagram.*/
         }catch(IOException e){
         e.printStackTrace();
        }I chose to use Datagram for my method to send the email. I thought about Tcp. I might change my mind. I am not going to write down the source of what is supposed to go here. What I just want to do here is take the message and the email address and send it. I must know if there is a way to make a byte[] and write a String to it. If I know this I would be able to send the message with Datagram. But even if I do get the datagram to work I wonder if the program will work.
    Thanks,
    George

    Never mind the previous post before this one that said about:
    ::So all I need to do is to use it in my public void run() method?
    I will figure it out with the api after I download the seperate javamail package and the JAF. I was looking through the api for Java 2 Platform, Standard Edition (J2SE). Thanks for telling me about the javax.mail api. If you didnt tell me i'd keep looking through the wrong api and not being aware that I have to download a seperate package.
    George

  • How can I change a string to a numeric when the numbers are separated by blank spaces?

    I would like to change a list of numbers in string to a list of number in numeric like in the attached vi. Unfortunately, the numbers are not separated by commas but by blank spaces. Which character can I use for the blank space?
    Ninskaya
    Attachments:
    readcommdelim.vi ‏19 KB

    Why don't you just use the Spreadsheet String to Array function instead. You can specify any delimiter you want. See the attached picture.
    Attachments:
    string_to_array.jpg ‏6 KB

  • Problem with Connection Manager. Can't change connection string / Server name

    p.MsoNormal, li.MsoNormal, div.MsoNormal
    {margin-top:0cm;margin-right:0cm;margin-bottom:10.0pt;margin-left:0cm;line-height:115%;font-size:11.0pt;font-family:'Calibri','sans-serif';}
    .MsoChpDefault
    {font-size:10.0pt;}
    .MsoPapDefault
    {line-height:115%;}
    @page Section1
    {size:612.0pt 792.0pt;margin:72.0pt 72.0pt 72.0pt 72.0pt;}
    div.Section1
    {page:Section1;}
    Hi,
    I have copied a number of SSID packages from a live server to my test server and am trying to get them up and running but I have a problem with the connection. The only thing that is different is the server name. I decided to keep the same connection in the connection manager as it is referenced in a dtsConfig file. I changed the dtsConfig file to reference the new servername [Data Source= new test server name]. I also check my paths and they are pointing to the correct config locations etc.
    I found this post which was similar to my problem but I still get problems with the connection
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1319961&SiteID=1
    I updated the connection by changing the server name in the actual connection. I did this from the data flow tab in the Connection Managers sections (MS Visual Studio). Right clicked - Edit - changed the name of the server name to my test server and selected the database. Test connection was fine, and saved this.
    Once I saved this, the connection string changed to my current test server in the properties of the connection. However when I run the package I get the following error:
    Error: 0xC0202009 at ReportsImport, Connection manager "myconnectionstring": SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
    An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Login timeout expired".
    An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.".
    An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Named Pipes Provider: Could not open a connection to SQL Server [53]. ".
    Error: 0xC020801C at Myprocess import from file, BuyAtReportsImport [79]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "myconnectionstring" failed with error code 0xC0202009.  There may be error messages posted before this with more information on why the AcquireConnection method call failed.
    Error: 0xC0047017 at Myprocess import from file, DTS.Pipeline: component "ReportsImport" (79) failed validation and returned error code 0xC020801C.
    Error: 0xC004700C at Myprocess import from file, DTS.Pipeline: One or more component failed validation.
    Error: 0xC0024107 at Myprocess import from file: There were errors during task validation.
    So even if I change the existing connection properties and save and Build my package again, my connection properties (connectionstring, servername etc) all revert back to its original data source when I re-open the package. Simply it does not seem to be saving the connection properties i put in.
    What am I doing wrong or how can I change the existing connection manager to look at the new server. The database is  the same and I have full admin privilege on the server.
    I don't want to recreate my packages as there are alot and they are not simple.
    After changing the connection properties, saving and reloading I get a connection error. But this is because it is not retaining the new connection manger setting i entered.
    Incidentally - I created a new SSID to perform a simple connection and write to the the server and it was OK so there is no problem with actually seeing the my test server.
    Thanks in advance

    Yes, the package is in visual studio and I have executed it. There are no errors but in the output i have the error message about my connection. My dtsConfig file is added to the project in the 'Package Configuration Organizer' and path and files are correct. This is the output error:
    Error: 0xC020801C at xx import from file, xxReportsImport [79]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "myconnectionname" failed with error code 0xC0202009.  There may be error messages posted before this with more information on why the AcquireConnection method call failed.
    I will try and run it using dtexec.exe. if I have two config files do i use
    dtsexec.exe /f <packagename> /conf <configfile> /conf <secondconfigfile>

  • Need to change a string.

    In my class we were required to write a program that will calculate the weekly pay of an employee. Then it also must allow the user to enter another employee until the user enters the word stop. The program must display the name, hours worked, payrate, and weekly pay. I used a while loop and have set it so that the user enters the employee name before the loop. The problem is if I try to rename the string the compiler says that variable employeeName has already been defined. I know now that you cannot change the name of a string that it is emutable, but what I don't understand is that the proffesor says I have to do it using boolean true and false. The biggest problem is that the school is online and is not giving us all the resources we need so I donot understand boolean values in depth like this to understand how to write the program correctly. If the user enters stop first it will skip the loop unles it will continue to use the same employee name over and over. Here is the code to help better understand:
    //Payroll Calculating Program
    import java.util.Scanner;
    public class Payroll2
    public static void main( String args [] )
    Scanner input = new Scanner( System.in );
    double hours;
    double payrate;
    System.out.println( "Please enter employee name, enter stop to exit program:" );
    String employeeName = input.nextLine();
    while ( !employeeName.equals( "stop" ))
    System.out.println( "Please enter hours worked this week:" );
    hours = input.nextDouble();
    System.out.println( "Please enter pay rate of employee:" );
    payrate = input.nextDouble();
    if ( hours < 0 ) {
    System.out.println( "Please enter a positive amount for hours worked:" );
    hours = input.nextDouble(); }
    else if ( payrate < 0 ) {
    System.out.println( "Please enter a positve amount for the pay rate:" );
    payrate = input.nextDouble(); }
    else if ( ( hours <= 40 ) & ( payrate >= 0 ) & ( hours >= 0 ) ) {
    System.out.printf( "%s worked for %.2f hours,\nHourly wage was: $%.2f per hour,\nIncome for this week before taxes was: $%.2f.\n",
    employeeName, hours, payrate, (hours * payrate) );}
    else if ( ( hours > 40 ) & ( payrate >= 0 ) ) {
    System.out.printf( "%s worked for %.2f hours,\nHourly wage was: $%.2f per hour,\nIncome for this week before taxes was: $%.2f.\n",
    employeeName[ counter ], hours, payrate, (( hours - 40 ) * ( payrate + ( payrate / 2 ) ) + ( payrate * 40 )) ); }
    System.out.println( "Payroll program is exiting, Goodbye." );
    }

    //Nicole Hammers
    //Payroll Calculating Program
    import java.util.Scanner;
    public class Payroll2
    public static void main( String args [] )
    Scanner input = new Scanner( System.in );
    double hours;
    double payrate;
    System.out.println( "Please enter employee name, enter stop to exit program:" );
    String employeeName = input.nextLine();
    while ( !employeeName.equals( "stop" ))
    System.out.println( "Please enter hours worked this week:" );
    hours = input.nextDouble();
    System.out.println( "Please enter pay rate of employee:" );
    payrate = input.nextDouble();
    if ( hours < 0 ) {
    System.out.println( "Please enter a positive amount for hours worked:" );
    hours = input.nextDouble(); }
    else if ( payrate < 0 ) {
    System.out.println( "Please enter a positve amount for the pay rate:" );
    payrate = input.nextDouble(); }
    else if ( ( hours <= 40 ) & ( payrate >= 0 ) & ( hours >= 0 ) ) {
    System.out.printf( "%s worked for %.2f hours,\nHourly wage was: $%.2f per hour,\nIncome for this week before taxes was: $%.2f.\n",
    employeeName, hours, payrate, (hours * payrate) );}
    else if ( ( hours > 40 ) & ( payrate >= 0 ) ) {
    System.out.printf( "%s worked for %.2f hours,\nHourly wage was: $%.2f per hour,\nIncome for this week before taxes was: $%.2f.\n",
    employeeName, hours, payrate, (( hours - 40 ) * ( payrate + ( payrate / 2 ) ) + ( payrate * 40 )) ); }
    System.out.println( "Payroll program is exiting, Goodbye." );
    This program will compile but the loop does not exit because the string cannot be changed.
    //Nicole Hammers
    //Payroll Calculating Program
    import java.util.Scanner;
    public class Payroll2
    public static void main( String args [] )
    Scanner input = new Scanner( System.in );
    double hours;
    double payrate;
    System.out.println( "Please enter employee name, enter stop to exit program:" );
    String employeeName = input.nextLine();
    while ( !employeeName.equals( "stop" ))
    System.out.println( "Please enter hours worked this week:" );
    hours = input.nextDouble();
    System.out.println( "Please enter pay rate of employee:" );
    payrate = input.nextDouble();
    if ( hours < 0 ) {
    System.out.println( "Please enter a positive amount for hours worked:" );
    hours = input.nextDouble(); }
    else if ( payrate < 0 ) {
    System.out.println( "Please enter a positve amount for the pay rate:" );
    payrate = input.nextDouble(); }
    else if ( ( hours <= 40 ) & ( payrate >= 0 ) & ( hours >= 0 ) ) {
    System.out.printf( "%s worked for %.2f hours,\nHourly wage was: $%.2f per hour,\nIncome for this week before taxes was: $%.2f.\n",
    employeeName, hours, payrate, (hours * payrate) );}
    else if ( ( hours > 40 ) & ( payrate >= 0 ) ) {
    System.out.printf( "%s worked for %.2f hours,\nHourly wage was: $%.2f per hour,\nIncome for this week before taxes was: $%.2f.\n",
    employeeName, hours, payrate, (( hours - 40 ) * ( payrate + ( payrate / 2 ) ) + ( payrate * 40 )) ); }
    System.out.println( "Please enter employee name, enter stop to exit program:" );
    String employeeName = input.nextLine();
    System.out.println( "Payroll program is exiting, Goodbye." );
    This progeam will not compile and the error says:
    Payroll2.java:45: employeeName is already defined in main(java.lang.String[])

Maybe you are looking for

  • Rep 1401"desc_thik_widformula" fatal pl/sql error

    Hi, This problem in a currently using report. the error is:- ' rep 1401"desc_thik_widformula" fatal pl/sql error' This error occurs when only selecting one of the parameters - name:- :Sub_inventory , Value :- 'Tube Lines' Last 31st July 2010 it worke

  • ITunes says this computer is authorized, but it doesn't take

    Just moved my stuff to a new iMac G5. Of course, I couldn't play my Music Store downloads, so I provided my apple id and password and authorized my computer to play them. iTunes confirmed that my computer was now authorized. However, it still won't l

  • ERROR IN PROCEDURE

    I'm trying to write a procedure that will compute the start and end dates of the weeks within a period, etc. Number of business days in a week is 5; that is, Monday to Friday. The first part of the code I have to write is giving me problems please he

  • Problem in running the servlet

    I have compiled the servlet and put the class file HelloWorld.class inside $CATALINA_HOME$/webapps/ROOT/WEB-INF/classes/ directory, under tomcat6.0.18 and also mapped servlet in $CATALINA_HOME$/webapps/ROOT/WEB-INF/web.xml, as below web.xml:     <?xm

  • Adding Node and Deleting Node in Tree

    Hi, I am building a tree dynamically. I have a class which has set of properties.I am constructing as follows. public class TreeNode         public function TreeNode()      public var friendlyName:String;      public var icon:Class;      [Bindable]