Go to Post For any coaches weary of choosing human players this year because you're worried they might lose their cool mid-game, a good indicator of someones ability to keep focused is their attitude while playing video games. - BradMello [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-02-2012, 19:18
Herbblood's Avatar
Herbblood Herbblood is offline
Knowledgeable
AKA: Ally
FRC #3044 (OxBE4)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2008
Location: Ballston Spa
Posts: 247
Herbblood is an unknown quantity at this point
Question Open text file

One of my teammates is trying to open a text file(.txt) on the robot. We not have found the correct methods.
Please respond! Thank you.
__________________
Off to WPI!
Go OxBE4
Reply With Quote
  #2   Spotlight this post!  
Unread 14-02-2012, 22:19
Jeanne Boyarsky Jeanne Boyarsky is offline
Java Mentor
FRC #0694 (StuyPulse)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: New York
Posts: 100
Jeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud ofJeanne Boyarsky has much to be proud of
Re: Open text file

There is a class called InputStreamReader available in Java ME (robot version) that can read from a file. If you search for InputStreamReader on the internet, you will find some examples of how to use it.
__________________
Team 694 mentor 2010-present, FIRST Volunteer and Co-organizer of FIRST World Maker Faire Tent
2012 NYC Woodie Flowers Finalist
2015 NYC Volunteer of the Year
Reply With Quote
  #3   Spotlight this post!  
Unread 14-02-2012, 23:31
Chiller Chiller is offline
Registered User
AKA: Connor Christie
FRC #4095 (RoXI Robotics)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Wisconsin
Posts: 118
Chiller is on a distinguished road
Re: Open text file

Quote:
Originally Posted by Jeanne Boyarsky View Post
There is a class called InputStreamReader available in Java ME (robot version) that can read from a file. If you search for InputStreamReader on the internet, you will find some examples of how to use it.
YuP
Reply With Quote
  #4   Spotlight this post!  
Unread 15-02-2012, 00:06
TravSatEE's Avatar
TravSatEE TravSatEE is offline
Spacecraft Engineer and more
FRC #2035 (Robo Rockin' Bots)
Team Role: Engineer
 
Join Date: Jan 2012
Rookie Year: 2002
Location: Monterey, CA
Posts: 26
TravSatEE is infamous around these partsTravSatEE is infamous around these parts
Re: Open text file

The best overview of the file read/write code I have seen is available in [1] around slide 7 with example code.

[1] http://www.usfirst.org/uploadedFiles...FRCKickoff.pdf
Reply With Quote
  #5   Spotlight this post!  
Unread 15-02-2012, 18:12
Herbblood's Avatar
Herbblood Herbblood is offline
Knowledgeable
AKA: Ally
FRC #3044 (OxBE4)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2008
Location: Ballston Spa
Posts: 247
Herbblood is an unknown quantity at this point
Exclamation Re: Open text file

Okay i got the FileConnection file = (FileConnection) it says unreported exception java.io.IOException must be caught or declared to be thrown,and when i do the try catch if still says that.
As well as i can't(when it is put as FileConnectionfile = new File Connection() is says that the sunsquack is abstract and cannot be instantiated.
Any ideas as what to do please?
If anyone has actual code to open a (.txt) file on netbeans it would be deeply apprectiated!
Thank you.
__________________
Off to WPI!
Go OxBE4

Last edited by Herbblood : 15-02-2012 at 18:59.
Reply With Quote
  #6   Spotlight this post!  
Unread 15-02-2012, 20:15
techkid86's Avatar
techkid86 techkid86 is offline
Magic Programer
FRC #3044 (0xBE4)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: ballston spa
Posts: 58
techkid86 is an unknown quantity at this point
Question Re: Open text file

we've looked at that, but we are still having issues. we want to open a text file that has a large number of double numbers seperated by newlines. the totoral posted are more directed at outputting(which is nice though) any other totorals or sites?

ty all in advance
__________________
"you can build a perfect machine out of imperfect parts" -Urza
Reply With Quote
  #7   Spotlight this post!  
Unread 16-02-2012, 16:57
ItzWarty ItzWarty is offline
Registered User
FRC #1072 (Harker Robotics)
Team Role: Leadership
 
Join Date: Jan 2012
Rookie Year: 2010
Location: California
Posts: 15
ItzWarty is an unknown quantity at this point
Re: Open text file

This interface is implemented on our version of Java:
http://developers.sun.com/mobility/a...ileconnection/

I'd assume that they wouldn't reinvent the wheel (or in this case, the API)

I've used that API for TCP Sockets
__________________
Leader of Team 1072. Software developer of RAF Manager.
Follow me on Twitter: Twitter.com/ItzWarty/
Reply With Quote
  #8   Spotlight this post!  
Unread 17-02-2012, 16:15
techkid86's Avatar
techkid86 techkid86 is offline
Magic Programer
FRC #3044 (0xBE4)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: ballston spa
Posts: 58
techkid86 is an unknown quantity at this point
Question Re: Open text file

we has this as code, but it only reads every other character.
ex.
in text file: 1234.5678
reads out: 2457

i have checked the character encoding, and it seems to be in ASCII. but, the read char is in Unicode. so i outputed the raw bytes, and converted it into ASCII, and the output just was the ASCII reprisentation.

DataInputStream dataStream=new DataInputStream("file:///FTPtest.txt");
char[] c=new char[9];
for (int i=0;i<9;i++)
{
c[i]=dataStream.readChar();
}
System.out.println(new String(c));


any suggestions?


found it.... nvm.... *face palm*
__________________
"you can build a perfect machine out of imperfect parts" -Urza

Last edited by techkid86 : 17-02-2012 at 18:12.
Reply With Quote
  #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
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:58.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi