View Single Post
Old 05-24-2011, 04:38 AM   PM User | #5
zverys36
New to the CF scene

 
Join Date: May 2011
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
zverys36 is an unknown quantity at this point
Smile

Quote:
Originally Posted by Fou-Lu View Post
Gotcha.
The easiest way would be to read the data in as a string, parse it as an integer and display it. Using a try/catch would suit for this.

PHP Code:
BufferedReader br;
try
{
    
br  = new BufferedReader(new Filereader("yourfile.txt"));
    
String sLine null;
    while (
null != (sLine br.readLine()))
    {
        
String sDisplay "";
        try
        {
            
sDisplay Integer.toBinaryString(Integer.parseInt(sLine).intValue());
        }
        catch (
NumberFormatException ex)
        {
            
sDisplay sLine;
        }
        
System.out.println("Line: " sDisplay);
    }
}
catch (
IOException ex)
{
    
System.out.println("Failed to open file.");
}
finally
{
    try
    {
        
br.close();
    }
    catch (
Exception ex)
    {
    }

Untested, but something like that should work.
Thanks, it worked!
zverys36 is offline   Reply With Quote