DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links