Thread: Open text file
View Single Post
  #9   Spotlight this post!  
Unread 17-02-2012, 20:44
Secretspy97 Secretspy97 is offline
Registered User
FRC #1126
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2009
Location: New York
Posts: 25
Secretspy97 is an unknown quantity at this point
Re: Open text file

this is how we have been able to open and read a text file which is terminated by a semi colon:

Code:
    private final String PATH = "file:///Sparx/mytxt.txt";
    private final char ESC_CHAR = ';';

try 
            {
                FileConnection read = (FileConnection) Connector.open(PATH, Connector.READ);
                fileRead =  read.openDataInputStream();
              
                String theString = ""; 
                while(true)
                {
                    byte ch = fileRead.readByte();
                     if(ch == ESC_CHAR)
                    {
                        break;
                    }
                    theString += (char) ch;
                }
Reply With Quote