Converting english to ascii using java


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Converting english to ascii using java

  1. #1
    Join Date
    Oct 2004
    Posts
    1

    Converting english to ascii using java

    anyone out there know how to Converting english to ascii using java
    cheers
    phil

  2. #2
    Join Date
    May 2004
    Location
    Durham, UK
    Posts
    174
    Hi.

    Just convert the string into a byte array
    and cycle through it printing out the items.

    i.e.

    Code:
    public class StringToAscii
    {
        public static void main(String[] args)
        {
            StringToAscii.convertString("A test");
        }
        
        public static void convertString(String s)
        {
            byte b[] = s.getBytes();
            for(int i = 0; i < b.length; i++)
            {
                System.out.println(b[i]);
            }
            
        }
        
    }
    Hope this helps.
    Last edited by JGRobinson; 10-27-2004 at 03:58 PM.
    Hope this helps
    Graham

    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, and if they get mad, you are a mile away and you have their shoes ;-)

    http://www.grahamrobinsonsoftware.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center