TextIO

public class Greeting {
/* This program asks the user's name and then
greets the user by name. This program depends
on the non-standard class, TextIO.
public static void main(String[] args) {
String usersName; // The user's name, as entered by the user.
String upperCaseName; // The user's name, converted to uppercase letters.
TextIO.put("Please enter your name: ");
usersName = TextIO.getln();
upperCaseName = usersName.toUpperCase();
TextIO.putln("Hello, " + upperCaseName + ", nice to meet you!");
} // end main()
} // end class
I got above program from below given link
http://www.faqs.org/docs/javap/c2/ex-2-3-answer.html
I am unable to compile this program as i am getting the below given error
3 errors found:
File: F:\practicals\oop\ROUGH\Greeting.java [line: 14]
Error: cannot find symbol
symbol : variable TextIO
location: class Greeting
File: F:\practicals\oop\ROUGH\Greeting.java [line: 15]
Error: cannot find symbol
symbol : variable TextIO
location: class Greeting
File: F:\practicals\oop\ROUGH\Greeting.java [line: 19]
Error: cannot find symbol
symbol : variable TextIO
location: class Greeting
i also tried using import statement like java.io.*; and java.util.*; at top
i am using: Dr Java IDE and have installed java 1.5
If anybody helps me it would be great help as i am strucked in begining of the tutorial, as author is using this TextIO class more often in his tutorial
Thanks in advance
Suresh
Call Coordinator
HP India
Bangalore
Edited by: suryafromkoppal on Jul 5, 2008 3:24 PM

suryafromkoppal wrote:
public class Greeting {
/* This program asks the user's name and then
greets the user by name. This program depends
on the non-standard class, TextIO.
*/That comment tells you - just as your compiler is telling you - that compiling your application depends on a class that is not part of the standard java library. You need to make sure that when you are compiling, you are including the location of the TextIO class in your classpath. I'd recommend reading the tutorial (I didn't check out the link), but I'm sure they provide some information on finding the TextIO class so that you can compile the examples.

Similar Messages

  • Having trouble finding out why i get   "cannot find symbol variable textio"

    Im trying to write a romanNumeral converter program.
    I dont know what else im doing wrong!
    Please help me to see and understand what i did wrong!

    Please help me to see and understand what i did wrong!You are using something called 'textio'
    The compiler doesn't know what that is.
    It is telling you exactly that.

  • Import textio.ConsoleIO

    i have been told to write a program using import textio.ConsoleIO but when i try to use it i am told it does not exsist

    There is no such package in the default API.
    Whoever told you too do such a thing (prof, teacher, book, on line tutorial) should have told you where to get the package.
    When you figure out where it is, download it or copy it to your machine.
    Then read about the -classpath or -sourcepath options to the java and javac commands to tell them where the package is.

  • TextIO problem

    I made the download of NetBeans IDE 4.0 and it doesn't recognise the TextIO.
    EX:
    int abc = TextIO.getInt();
    What do I do ?
    Is there any other way to input text ?

    I made the download of NetBeans IDE 4.0 and itdoesn't recognise the TextIO.
    EX:
    int abc = TextIO.getInt();
    What do I do ? Is there any other way to input text ?I just took a quick peek at the Javadocs for all the core classes, but TextIO
    isn't part of it. This means that you have to tell your IDE that you're using that
    particular class; I'm sure your IDE has an option for that. Make sure that you've
    installed that particular class somewhere ...
    kind regards,
    Jos
    ps. there are numerous other ways to get text from an InputStream ...

  • Writing data into files using VHDL Textio

    Hi 
    I was trying to write nos. from 1 to 8 into a text file using the below program.
    process
    type IntegerFileType is file of integer;
    file data_out: IntegerFileType ;
    variable fstatus: FILE_OPEN_STATUS;
    variable coun: natural:= 1;
    begin
    file_open(fstatus,data_out,"myfile.txt",write_mode);
    for i in 1 to 8 loop
    write(data_out, coun);
    coun := coun + 1;
    end loop;
    file_close(data_out);
    wait; -- an artificial way to stop the process
    end process;
    But getting the below attached result..
    Can you please help me out what could be wrong with the program.
    Thanks & regards
    Madhur

    Do you want the numbers in the file to be human readable ASCII?
    Then you'll need to convert your coun to a string. 
    declare another variable of type line (type access to string).
    do a write() to the line, then a writeline() to the file.
    natural'image(coun) will convert coun to a string.
    Google should help you find example code that will help.

  • Can I write to a text file on local HDD from forms appl?

    Hi All,
    We have 8i database being accessed by 6i forms application using web-based arch. Clients are on windowsNT/window2000. Is it possible to dump some data in a text file from forms application (by pressing a button) on local hard disk? User is looking something similar to sqlplus spool in forms 6i. Is this possible? User is specific about file being created in local machine and not on server(utl_file/dbms_pipe). Any ideas?
    Thanks.

    You can find explanation and a quick start guide on PJCs on the Forms Upgrade Center at:
    I think the following code can give you a starting point for a PJC (based on text_item) that will do it.
    Also you will need to sign this JAR because you want to access the client machine - see the sigining paper on OTN.
    To activate this PJC you will use something like SET_CUSTOM_PROPERTY ('text_item1', 1, 'WRITE', :text_item1);
    In your form.
    import oracle.forms.ui.VTextField;
    import java.io.FileOutputStream;
    import oracle.forms.properties.ID;
    public class textio extends VTextField
    public final static ID WRITE = ID.registerProperty("WRITE");
    String a = "hello";
    public textio()
    public boolean setProperty(ID p0, Object p1)
    if (p0==WRITE)
    try
    FileOutputStream fileOut = new FileOutputStream("c:\\temp\\textio.txt");
    fileOut.write(p1.toString().getBytes());
    fileOut.close();
    } catch (Exception ex)
    ex.printStackTrace();
    }

  • How to Implement simple Timer in this code

    Hi there guys,
    This is a small ftp client that i wrote. It has encryption and all bulit into it. I want to initiate the sendfile function every 5 minutes.
    The program starts with the displaymenu function wherein a menu with various options is displayed.
    How Do i Do that? I went online and tried doing it myself but cud not possibly think of a reason as to why my changes were not working.
    Here is the basic code. I earnestly hope that some of you guys out there will help me. This is a very simple problem and sometimes it is the finer point that eludes us. any help will be deeply appreciated
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    import javax.crypto.*;
    import java.util.regex.*;
    import javax.crypto.spec.PBEKeySpec;
    import javax.crypto.spec.PBEParameterSpec;
    import java.security.spec.AlgorithmParameterSpec;
    import java.security.spec.KeySpec;
    class FTPClient
         public static void main(String args[]) throws Exception
              Socket soc=new Socket("127.0.0.1",5217);
              transferfileClient t=new transferfileClient(soc);
              t.displayMenu();          
    class transferfileClient
         Socket ClientSoc;
         DataInputStream din;
         DataOutputStream dout;
         BufferedReader br;
         transferfileClient(Socket soc)
              try
                   ClientSoc=soc;
                   din=new DataInputStream(ClientSoc.getInputStream());
                   dout=new DataOutputStream(ClientSoc.getOutputStream());
                   br=new BufferedReader(new InputStreamReader(System.in));
              catch(Exception ex)
         //encrypto routine starts
    class DesEncrypter {
           Cipher ecipher;
            Cipher dcipher;   
            // 8-byte Salt
            byte[] salt = {
                (byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
                (byte)0x56, (byte)0x35, (byte)0xE3, (byte)0x03
            // Iteration count
            int iterationCount = 19;   
            DesEncrypter(String passPhrase) {
                try {
                             // Create the key
                             KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount);
                             SecretKey key = SecretKeyFactory.getInstance(
                             "PBEWithMD5AndDES").generateSecret(keySpec);
                             ecipher = Cipher.getInstance(key.getAlgorithm());
                             dcipher = Cipher.getInstance(key.getAlgorithm());   
                             // Prepare the parameter to the ciphers
                             AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);   
                             // Create the ciphers
                             ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
                             dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
                } catch (java.security.InvalidAlgorithmParameterException e) {
                } catch (java.security.spec.InvalidKeySpecException e) {
                } catch (javax.crypto.NoSuchPaddingException e) {
                } catch (java.security.NoSuchAlgorithmException e) {
                } catch (java.security.InvalidKeyException e) {
            // Buffer used to transport the bytes from one stream to another
            byte[] buf = new byte[1024];   
            public void encrypt(InputStream in, OutputStream out) {
                try {
                    // Bytes written to out will be encrypted
                    out = new CipherOutputStream(out, ecipher);   
                    // Read in the cleartext bytes and write to out to encrypt
                    int numRead = 0;
                    while ((numRead = in.read(buf)) >= 0) {
                        out.write(buf, 0, numRead);
                    out.close();
                } catch (java.io.IOException e) {
            public void decrypt(InputStream in, OutputStream out) {
                try {
                    // Bytes read from in will be decrypted
                    in = new CipherInputStream(in, dcipher);   
                    // Read in the decrypted bytes and write the cleartext to out
                    int numRead = 0;
                    while ((numRead = in.read(buf)) >= 0) {
                        out.write(buf, 0, numRead);
                    out.close();
                } catch (java.io.IOException e) {
    }     //encryptor routine ends          
         void SendFile() throws Exception
                             String directoryName;  // Directory name entered by the user.
                             File directory;        // File object referring to the directory.
                             String[] files;        // Array of file names in the directory.        
                             //TextIO.put("Enter a directory name: ");
                             //directoryName = TextIO.getln().trim();
                             directory = new File ( "E:\\FTP-encrypted\\FTPClient" ) ;           
                        if (directory.isDirectory() == false) {
                        if (directory.exists() == false)
                        System.out.println("There is no such directory!");
                        else
                        System.out.println("That file is not a directory.");
                else {
                    files = directory.list();
                    System.out.println("Files in directory \"" + directory + "\":");
                    for (int i = 0; i < files.length; i++)
                             String patternStr = "xml";
                             Pattern pattern = Pattern.compile(patternStr);
                             Matcher matcher = pattern.matcher(files);
                             boolean matchFound = matcher.find();
                                       if (matchFound) {
                                       dout.writeUTF("SEND");
                                       System.out.println(" " + files[i]);                                        
                                       String filename;
                                       filename=files[i];
                                       File f=new File(filename);
                                       dout.writeUTF(filename);
              String msgFromServer=din.readUTF();
              if(msgFromServer.compareTo("File Already Exists")==0)
                   String Option;
                   System.out.println("File Already Exists. Want to OverWrite (Y/N) ?");
                   Option=br.readLine();               
                   if(Option=="Y")     
                        dout.writeUTF("Y");
                   else
                        dout.writeUTF("N");
                        return;
              System.out.println("Sending File ...");
                   // Generate a temporary key. In practice, you would save this key.
                   // See also e464 Encrypting with DES Using a Pass Phrase.
                   System.out.println("Secret key generated ...");
                   // Create encrypter/decrypter class
                   DesEncrypter encrypter = new DesEncrypter("My Pass Phrase!");
                   // Encrypt
                   FileInputStream fino=new FileInputStream(f);
                   System.out.println("Initialised ...");
                   encrypter.encrypt(fino,
                   new FileOutputStream("ciphertext.txt"));
                   System.out.println("generated ...");
                   fino.close();
                   FileInputStream fin=new FileInputStream("ciphertext.txt");
              int ch;
              do
                   ch=fin.read();
                   dout.writeUTF(String.valueOf(ch));
              while(ch!=-1);
              fin.close();          
              boolean success = (new File("ciphertext.txt")).delete();
                   if (success) {
                                  System.out.println("temp file deleted .../n/n");
              for (int j = 0; j < 999999999; j++){}
    }//pattermatch loop ends here
    else
                             { System.out.println("   " + "Not an XML file-------->" +files[i]); }
              }// for loop ends here for files in directory
                   }//else loop ends for directory files listing
         System.out.println(din.readUTF());                    
         }//sendfile ends here
         void ReceiveFile() throws Exception
              String fileName;
              System.out.print("Enter File Name :");
              fileName=br.readLine();
              dout.writeUTF(fileName);
              String msgFromServer=din.readUTF();
              if(msgFromServer.compareTo("File Not Found")==0)
                   System.out.println("File not found on Server ...");
                   return;
              else if(msgFromServer.compareTo("READY")==0)
                   System.out.println("Receiving File ...");
                   File f=new File(fileName);
                   if(f.exists())
                        String Option;
                        System.out.println("File Already Exists. Want to OverWrite (Y/N) ?");
                        Option=br.readLine();               
                        if(Option=="N")     
                             dout.flush();
                             return;     
                   FileOutputStream fout=new FileOutputStream(f);
                   int ch;
                   String temp;
                   do
                        temp=din.readUTF();
                        ch=Integer.parseInt(temp);
                        if(ch!=-1)
                             fout.write(ch);                         
                   }while(ch!=-1);
                   fout.close();
                   System.out.println(din.readUTF());
         public void displayMenu() throws Exception
              while(true)
                   System.out.println("[ MENU ]");
                   System.out.println("1. Send File");
                   System.out.println("2. Receive File");
                   System.out.println("3. Exit");
                   System.out.print("\nEnter Choice :");
                   int choice;
                   choice=Integer.parseInt(br.readLine());
                   if(choice==1)
                        SendFile();
                   else if(choice==2)
                        dout.writeUTF("GET");
                        ReceiveFile();
                   else
                        dout.writeUTF("DISCONNECT");
                        System.exit(1);

    here is a simple demo of a Timer usage.
    public class Scheduler{
        private Timer timer = null;
        private FTPClient client = null;
        public static void main(String args[]){
            new Scheduler(5000); 
        public Scheduler(int seconds) {
            client = new FTPClient();
            timer = new Timer();
            timer.schedule(new fileTransferTask(), seconds*1000);
            timer.scheduleAtFixedRate(new FileTransferTask(client), seconds, seconds);  
    public class FileTransferTask extends TimerTask{
        private FTPClient client = null;
        public FileTransferTask(FTPClient client){
            this.client = client;
        public void run(){
            client.sendFile();
    public class FTPClient{
        public void sendFile(){
             // code to send the file by FTP
    }the timer will will schedule the "task": scheduleAtFixRate( TimerTask, long delay, long interval)
    It basically spawn a thread (this thread is the class that you
    implements TimerTask..which in this example is the FileTransferTask)
    The thread will then sleep until the time specified and once it wake..it
    will execute the code in the the run() method. This is why you want to
    pass a reference of any class that this TimerTask will use (that's why
    we pass the FTPClient reference..so we can invoke the object's
    sendFile method).

  • Opening an *.txt file in oracle forms 4.5

    I am facing this problem I want to call an text file from a certain location and display the same when an user hits a particular button which has to be done in Oracle Forms 4.5.
    Could u pls help me

    If you want to display the *.txt file use ole object to do that and if you want to read the data from the text file and display in the text field then use textio package.
    Hope this helps you.
    Regards
    Gaurav

  • Help (Timed program)

    I�ve done this game, that if the user takes more than 30 sec. to answer, the program, when the user answer, tells that the time has been more that 30 sec. so the answer is not valid;
    I would like that the program, during the time the user is answering, displays the time passing and when it reaches 30 sec. it stops and says to the user that the time has passed, and that there is no more time, so the correct answer would be (for example) **-;
    Does someone knows how to do this?
    Thank�s for all your posts!
    import java.io.*;
    public class J24{
        public static void main(String[] args){
            String[] game, result;
            game=new String[3176];
            result=new String[3176];
            TextReader readfile;
            String name="JOGO24.txt";
            try{
                readfile = new TextReader(new FileReader(name));
            catch (TextReader.Error e) {
                System.out.println("\n\n\nAN ERROR OCURRED DURING READING FILE!");
                return;
            catch (FileNotFoundException e) {
                return;
            char c1, c2, c3, c4;
            int count;
            count=0;
            try{
                while(readfile.eof()==false){
                    c1=readfile.getChar();
                    c2=readfile.getChar();
                    c3=readfile.getChar();
                    c4=readfile.getChar();
                    String str = new StringBuffer().append(c1).append(c2).append(c3).append(c4).toString();
                    game[count]=str;
                    c1=readfile.getChar();
                    c2=readfile.getChar();
                    c3=readfile.getChar();
                    String str2= new StringBuffer().append(c1).append(c2).append(c3).toString();
                    result[count]=str2;
                    count++;
            finally{
                readfile.close();
            int ran=0;
            String  Res;
            ran=(int)(Math.random()*3176)+1;
            boolean rpt=false;
            while (rpt==false){
                System.out.println("\n\nI ll give you 4 numbers and you have to find 4 operations to give 24. Ex.:");
                System.out.println("8802");
                System.out.println("8+8+0*2=24; You enter: ++*");
                System.out.println("\n---YOU HAVE 30 SECONDS!!!---");
                System.out.println("\nOk?");
                rpt=TextIO.getBoolean();
            ran=(int) (Math.random()*3176)+1;
            System.out.println("\n\n");
            System.out.println("Number to be 24: "+game[ran]);//ran
            long startTime = System.currentTimeMillis();
            Res=TextIO.getWord();
            long endTime= System.currentTimeMillis();
            if(endTime-startTime>30000){
                System.out.println("");
                System.out.println("Your Passed 30 Seconds!!!");
                if(Res==result[ran]){//ran
                    System.out.println("But, in any case it is correct");
                }else{
                    System.out.println("And the correct answer would be "+ result[ran]);
                System.exit(0);
            if(Res==result[ran]){//ran
                System.out.println("Correct!");
            }else{
                System.out.println("Correct answer would be "+ result[ran]);
    }

    Hi,
    Which hardware are you using??
    Nevertheless, you will find an example VI with examples shipped with labVIEW called "temperature system demo.vi" a simulated temperature measurement program.
    replace the temp simulation with hardware thermocouple acquisition VI's
    That VI it might suit your purpose
    find attached that VI
    Any doubts, do get back
    regards
    Dev
    Message Edited by devchander on 03-08-2006 10:48 PM
    Attachments:
    Temperature System Demo.llb ‏188 KB

  • Can't compile - URGENT

    hi. hope someone can help. this is important, it's for my coursework at uni.
    I have downloaded the new java 1.4.1_01 and installed. i set the paths in my IDE to it, everything great, but if I compile, it says:
    "Registry key 'Software\JavaSoft\Java Runtime Environment\CurrentVersion'
    has value '1.4', but '1.3' is required.
    Error: could not find java.dll
    Error: could not find Java 2 Runtime Environment."
    How do I fix it?????
    Before, all was fine with JDK 1.3.1 but then problems happened, tried re-installing, no luck so I moved to the new version, this is what is happening.
    PLEASE this is urgent, can someone help?
    thanks

    a right...someone from my uni must have the same problem.
    any way, problem sorted, I re-installed the JDK and SDK and it's working now.
    but how can I import the .java files I need for my course?
    I have this code:
    import textio.ConsoleIO;
    import Date;
    import Calander;
    public class mainapplication {
         public static void main(String[] args)
    but it produces an error:
    C:\coursework2\mainapplication.java:16: '.' expected
    import Date;
    ^
    C:\coursework2\mainapplication.java:17: '.' expected
    import Calander;
    ^
    C:\coursework2\Date.java:15: package Calander does not exist
    import Calander.java;
    ^
    3 errors
    Process completed.
    what should I do?
    I tried deleting the .java; but that didn't help at all.
    any help, is appreciated

  • Webutil and SQLLDR

    It used to be on the client server when we run a batch file with sqlldr from a form, a cmd window would open and we can actually see a count of the records, and if we want we could make it that the user would have to click a button to close the cmd window and return to the form.
    Now with the web version and webutil, I was able to make the batch file work and the data is loaded into a table, however, when the cmd window opens, it stays blank and you cannot see what is happening.
    Is there a way to get the same performance as the client server version?
    Thanks
    George

    Hi,
    You can read the output/log file using textio (implemented through webutil)
    and give a message to the end user.
    Alternatively use the webutil host to open a command window and pass batch file which will do the sql ldr ....
    Rajesh Alex

  • Can someone test a prog for me, and help reading from an exty file

    Okay, I have a program to calculate the Pearson product-moment correlation coefficient ( http://en.wikipedia.org/wiki/Pearson_correlation_coefficient ) from an external file that I've just written for an assignment on Monday.
    I can't actually run it because I can't find a machine with Java on that works, though I can compile it. Why is a long story, but University Admin are going to feel my wrath.
    I would like two things.
    1) would someone be kind enough to try to run it and test it in anyway and report any bugs or inadequacies back to me. (you will need to create a text file called data.dat with some numbers in, e.g.
    14.234 54.4534
    376.56 432.2332
    23432. 23234.23
    2) How can I can the computer to ask the user to enter either a) the name of the file from system.in or b) from a popup dialogue box with a browse feature (or is that incompatible with some OSs?).
    The file follows:
    // Import packages
         import java.io.*; // Import all the Java input/output packages
         import java.util.StringTokenizer; // Import a utility package
    class Pearsontwo
    public static void main (String[] args)
         /* Define variables.
              (double any number with decimal point.
              ints take integer value) */
              double     sumx, sumy,               // sum of x and sum of y
                        sumxx, sumyy,          // sum of x squared and y squared
                        sumxy;                    // sum of products of x and y
              int n;                              // n is number of lines
         // Set name of file to be read
              String fileName = data.dat; // define the name of the file
         //     (Enhancement: use user input. This requires the use of System.in which is a bit complicated.
              //System.out.print("Please type the name of the file you wish to run the analysis on:");
              //fileName = TextIO.getInt();
         // Set things for reading external file
    BufferedReader br;     // Will be used to read the file
    String line;          // Will be used to hold a line read from the file
    StringTokenizer st; // Will be used to break a line into separate words
              String firstWord, secondWord;     // File will be read as string type
    double firstNumber, secondNumber;     // that need to be converted into numbers.
    try // if an error occurs, go to the "catch" block below
    // Create a buffered file reader for the file
         br = new BufferedReader (new FileReader(fileName));
    // Continue to read lines whilst there is one or more left to read
                        while (br.ready())
                        {   line= br.readLine();               // Read one line of the file
                             st = new StringTokenizer(line);     // Prepare to split the line into "words"
                             // Get the first two words (invalid --> error --> catch)
                                  firstWord = st.nextToken();
                                  secondWord = st.nextToken();
                             // Turn words into numbers (invalid --> error --> catch)
                                  firstNumber = Double.parseDouble(firstWord);
                                  secondNumber = Double.parseDouble(secondWord);
                             // Add the numbers to the previously stored numbers
                                  sumx = sumx + firstNumber;
                                  sumy = sumy + secondNumber;
                                  sumxx = sumxx + (firstNumber * firstNumber);
                                  sumyy = sumyy + (secondNumber * secondNumber);
                                  n = n++; add one to the value of n.
    // Close the file
    br.close();
    // Handle any error in opening the file
                   catch (Exception e)
                   {   System.err.println("File input error.\nPlease amend the file " + fileName);
              //     Calcuate r in stages, variance and covariance first.
                   double variancex = (sumx2 - (sumx * sumx / n)) / (n - 1);     // calculates the variance of x ...
                   double variancey = (sumx2 - (sumx * sumx / n)) / (n - 1);     // ... and y
                   double covariance = (sumx * sumy - sumx * sumy / n ) / (n - 1);     // and the covariance of x and y
                   double r = covariance / Math.sqrt(variancex * variancey);     // and the Pearson r value
                   // Printout
                   System.out.print("The Pearson product-moment correlation for these data is:" );
                   System.out.println ( r );
                   // Also print to file ?
    Cheers,
    Duncan.
    (Note: this is my own work by Duncan Harris at Cariff University, so I'm not plaigerising anyone other than myself if I post it here and it subsequently gets found by one of the course organisers who have given permission for this sort of thing anyway!)

    "I can't actually run it because I can't find a machine with Java on that works, though I can compile it. Why is a long story, but University Admin are going to feel my wrath."
    I'm sure they're worried.
    I don't understand this. You can compile, but not run? This makes no sense at all.
    Why can't you simply download the JDK from Sun and install it on a machine? You could both compile and run then.
    You don't need a pop-up dialog box to get an input file name from a user. The command prompt is quite sufficient.

  • Reading from text file gives IndexOutOfBoundsException error

    Dear All
    I really need your help in doing my assignment as soon as possible
    I am reading from a text file the following data
    4231781,Ali,AlAli
    4321790,Adnan,AlAli
    using two classes first one is
    public class Student
    private String studFName;
    private String studLName;
    private String studID;
    private double assignment1;
    private double assignment2;
    private double final_exam;
    private double total;
    public String getstudfName() {
    return studFName;
    public void setstudfName(String studFName) {
    this.studFName = studFName;
    public String getstudlName() {
    return studLName;
    public void setstudlName(String studLName) {
    this.studLName = studLName;
    public String getstudid() {
    return studID;
    public void setStudID(String studID){
    this.studID = studID;
    public double getAssignment1() {
    return assignment1;
    public void setAssignment1(double Assignment1) {
    this.assignment1 = assignment1;
    public double getAssignment2() {
    return assignment1;
    public void setAssignment2(double Assignment2) {
    this.assignment2 = assignment2;
    public double getFinal_exam() {
    return final_exam;
    public void setFinal_exam(double final_exam) {
    this.final_exam = final_exam;
    public double getTotal() {
    return total;
    public void setTotal(double total) {
    this.total = total;
    Student[] students = new Student[30];
    the second is manager one which is:
    import java.io.*;
    import java.io.IOException;
    import java.util.Arrays;
    import java.util.ArrayList;
    public class manager {
    public static Student[] students = new Student[30];
    public static void main(String args[]) {
    // We want to let the user specify which file we should open
    // on the command-line. E.g., 'java TextIO TextIO.java'.
    if(args.length != 1) {
    System.err.println("usage: java manager (file_name)");
    System.exit(1);
    // We're going to read lines from 'input', which will be attached
    // to a text-file opened for reading.
    BufferedReader input = null;
    try {
    FileReader file = new FileReader(args[0]); // Open the file.
    input = new BufferedReader(file); // Tie 'input' to this file.
    catch(FileNotFoundException x) { // The file may not exist.
    System.err.println("File not found: " + args[0]);
    System.exit(2);
    // Now we read the file, line by line, echoing each line to
    // the terminal.
    try {
    String line;
    // Student[] students = new Student[30];
    while( (line = input.readLine()) != null ) {
    // System.out.println(line);
    int m = line.indexOf(",");
    int j = line.lastIndexOf(",");
    String sID = line.substring(0,m);
    String sfn = line.substring(m+1,j) ;
    String sln = line.substring(j+1);
    int n = 0;
    students[n] = new Student();
    students[n].setStudID(sID);
    students[n].setstudfName(sfn);
    students[n].setstudlName(sln);
    students[n].setAssignment1(0.0);
    students[n].setAssignment2(0.0);
    students[n].setFinal_exam(0.0);
    students[n].setTotal(0.0);
                        ++n;
    catch(IOException x) {
    x.printStackTrace();
    // Arrays.sort(Student.students);
         int length = args.length;
    System.out.println();
    // System.out.println("Sorted by stuID");
    for (int i=0; i<length; i++) {
    System.out.print("Student ID "+students.getstudid() + "|||");
    System.out.print("Student Fname "+students[i].getstudfName() + "|||");
    System.out.print("Student name "+students[i].getstudlName());
    when I comile progrma it doesn't give any error but when I run it gives me the following exception:
    java.lang.String.substring. IndexOutOfBoundsException string index out of range : -1
    as can be seen from the manager class I form the read line from readline method as follows:
    int m = line.indexOf(",");
    int j = line.lastIndexOf(",");
    String sID = line.substring(0,m);
    String sfn = line.substring(m+1,j) ;
    String sln = line.substring(j+1);
    Therefore, student ID should be read from the beggining tel the character before the comma (,) then from the character after first comma tel that before second comma will be firstname, finally the rest after second comma will be last name.
    I want my program to read all lines in the text file and put them in order as above forming the array like database record and print them all.
    Could you please Help me in this matter friends as soon as possible.
    Regards,
    Java_Hobby

    please, format you code first (select your java code and hit the code button), then post all the error log message.

  • Java Interface as problems

    Hi this code for java i am having major problems. I am a newbie to java so please be kind and hope in the feature i can master java and then help to each others. I will include the show GUI class later.
    My main problem is how to assign events to the button so that it preforms a calculation.
    Second what should make my GUI run properly and what actions do i need to take.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ConvertValues extends JPanel {
    public class ConvertValues {
         JFrame window;
         JComboBox inputcombo,outputcombo;
         JRadioButton Length,Mass,Volume,Temperature;
         JButton = new JButton("Convert");
         JTextField outputtext, inputtext;
         public ConvertValues(){
              window = new JFrame("Imperial to Metric Converter");
              window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              window.setSize(600,600);
              window.setVisible(true);
              addRadioButtons();
              addComboBox();     
              public void addPanel(){
              Public JPanel getPanel();
              JPanel wrapper = new JPanel();
              wrapper.setLayout(new BorderLayout());
              wrapper.setBorder(BorderFactory.createEmptyBorder(13,13,13,13));
              JPanel centre = new JPanel ();
              centre.setLayout(new GridLayout(2,2));
              public void addRadiobButton(){
              JRadioButton RadioButton = new JRadioButton();
              JPanel rbut = new JPanel();
              rbut1.setLayout(new GridLayout(4,4));
              JPanel panel1 = new JPanel();
              JLabel metric = new JLabel (" Length Metric Values")
              panel1.add(metric);
              rbut1.add (panel1);
              JPanel panel2 = new JPanel();
              JTextField text1 = new JTextField (13);
              panel2.add(text1);
              rbut1.add(panel2);
              JPanel panel3 = new JPanel();
              JLabel imperial = new JLabel ("Length Imperial Values")
              panel3.add(Imperial);
              rbut1.add (panel3);
              JPanel panel4 = new JPanel();
              JTextField text2 = new JTextField (13);
              panel4.add(text2);
              rbut1.add(panel4);
              JPanel rbut2 = new JPanel();
              rbut2.setLayout(new GridLayout (4,4));
              JPanel panel5 = new JPanel ();
              JLabel metric2 = new JLabel ("Liquid Metric Values");
              panel5.add(metric2)
              rbut2.add(panel5);
              JPanel panel6 = new JPanel ();
              JTextField text3 = new JTextField (13);
              panel6.add(text3);
              rbut2.add(panel6);
              JPanel panel7 = new JPanel ();
              JLabel imperial2 = new JLabel ("Liquid Imperial Values");
              panel5.add(imperial2)
              rbut2.add(pane7);
              JPanel panel8 = new JPanel ();
              JTextField text4 = new JTextField (13);
              panel8.add(text4);
              rbut2.add(panel8);
              JPanel rbut3 = new JPanel();
              rbut3.setLayout(new GridLayout (4,4));
              JPanel panel9 = new JPanel ();
              JLabel metric3 = new JLabel (" Mass Metric Values");
              panel9.add(metric3)
              rbut3.add(panel9);
              JPanel panel10 = new JPanel ();
              JTextField text5 = new JTextField (13);
              panel10.add(text5);
              rbut3.add(panel10);
              JPanel panel11 = new JPanel ();
              JLabel imperial3 = new JLabel ("Mass Imperial Values");
              panel11.add(imperial3)
              rbut3.add(pane11);
              JPanel panel12 = new JPanel ();
              JTextField text6 = new JTextField (13);
              panel12.add(text6);
              rbut3.add(panel12);
              JPanel rbut4 = new JPanel();
              rbut4.setLayout(new GridLayout (4,4));
              JPanel panel13 = new JPanel ();
              JLabel metric4 = new JLabel (" Temperature Metric Values");
              panel13.add(metric4)
              rbut4.add(panel13);
              JPanel panel14 = new JPanel ();
              JTextField text6 = new JTextField (13);
              panel14.add(text6);
              rbut4.add(panel14);
              JPanel panel15 = new JPanel ();
              JLabel imperial4 = new JLabel ("Temperature Imperial Values");
              panel15.add(imperial4)
              rbut4.add(pane15);
              JPanel panel16 = new JPanel ();
              JTextField text7 = new JTextField (13);
              panel16.add(text7);
              rbut4.add(panel16);
              radiopanel.add("Length","rbut1")
              radiopanel.add("Liquid Mass","rbut2")
              radiopanel.add("Mass","rbut3")
              radiopanel.add("Temperature","rbut4")
              public void addComboBox(){
              JPanel panel17 = new JPanel();
              String[] str = {"Milliimeters", "Centimeters", "Meters", "Kilometers"};
              JComboBox metricvalues = newJComboBox(str);
              panel17.add(metricvalues);
              rbut1.add(panel17);
              JPanel panel18 = new JPanel();
              String[] str2 = {"Inch", "Foot", "Yard", "Mile"};
              JComboBox imperialvalues = newJComboBox(str2);
              panel18.add(imperialvalues);
              rbut1.add(panel18);
              JPanel panel19 = new JPanel();
              String[] str3 = {"Litres", "Millilitres", "Litres"};
              JComboBox metricvalues = newJComboBox(str3);
              panel19.add(metricvalues);
              rbut2.add(panel19);
              JPanel panel20 = new JPanel();
              String[] str4 = {"Fluid", "Ounce", "Pint", "Quart", "Gallon"};
              JComboBox imperialvalues = newJComboBox(str4);
              panel20.add(imperialvalues);
              rbut2.add(panel20);
              JPanel panel21 = new JPanel();
              String[] str5 = {"Grammes", "Kilogrammes", "Metric Tonne"};
              JComboBox metricvalues = newJComboBox(str5);
              panel21.add(metricvalues);
              rbut3.add(panel21);
              JPanel panel22 = new JPanel();
              String[] str6 = {"Ounce", "Pound", "Stone", "Long Ton"};
              JComboBox imperialvalues = newJComboBox(str6);
              panel22.add(imperialvalues);
              rbut3.add(panel22);
              JPanel panel23 = new JPanel();
              String[] str6 = {"Grammes", "Kilogrammes", "Metric Tonne"};
              JComboBox metricvalues = newJComboBox(str6);
              panel23.add(metricvalues);
              rbut4.add(panel23);
              JPanel panel24 = new JPanel();
              String[] str7 = {"Ounce", "Pound", "Stone", "Long Ton"};
              JComboBox imperialvalues = newJComboBox(str7);
              panel24.add(imperialvalues);
              rbut4.add(panel24);
              frame.getContentPane().add(center, BorderLayout.CENTER);
              public void addLabelandtext();{
              inputlabel = new JLabel("Enter Value");
              valuelabel = new JLabel("0");
              metricLabel = new JLabel ("Metric Value");
              imperial value = new JLabel("Imperial Value");
              outputtext = new JTextField(8);
              inputtext = new JTextField (8);
              JPanel labelpanel = new JPanel();
              labelpanel.add(inputlabel);
              labelpanel.add(mJPanel panel25 = new JPanel();
              labelpanel.add(imperiallabel);
              labelpanel.add(valuelabel);
              labelpanel.add(outputtext);
              labelpanel.add(inputtext);
              JPanel top = new JPanel(new GridLayout(5,3));
              middle.add(labelpanel);
              frame.getContentPane().add(middle,BorderLayout.SOUTH);
              public void ConvertButton();{
                   JPanel panel25 = new JPanel();
                   JButton convert = new JButton ("CONVERT");
                   Convert.addActionListener(this);
                   panel25.add(convert);
                   rbut1.add(panel 25));
                   JPanel panel26 = new JPanel();
                   JButton convert = new JButton ("CONVERT");
                   Convert.addActionListener(this);
                   panel26.add(convert);
                   rbut2.add(panel 26));
                   JPanel panel27 = new JPanel();
                   JButton convert = new JButton ("CONVERT");
                   Convert.addActionListener(this);
                   panel27.add(convert);
                   rbut3.add(panel 27));
                   JPanel panel28 = new JPanel();
                   JButton convert = new JButton ("CONVERT");
                   Convert.addActionListener(this);
                   panel28.add(convert);
                   rbut4.add(panel 28));
              public void LengthConverter();{
              Let measurement = TextIO.getDouble()
              Let units = TextIO.getlnword();
              if the units are inches
                   Let inches = measurement
              else if the units are milimeters
                   Let inches = measurement*25.4
              else if the units are Foot
                   Let centirmeter = measurement*30.48
              else if the units are Yard
                   Let meter = measurement*0.9144
              else if the units are mile
                   let kilometers = measurement*1.609
              else if the unit are meters
                   let centimeters = measurement*100
              else
                   The units are wrong!
                   Print an error message and stop processing
              let milimeter = inches/25.4
              let foot = centimeters/30.48
              let Yard = meter/0.9144
              let mile = kilometers/1.609
              let meter = centimeter/100
              dispay the results
              public void VolumeConverter();{
                   Let measurement = TextIO.getDouble()
              Let units = TextIO.getlnword();
              if the units are Fluid Ounce
                   Let Fluid Ounce = measurement
              else if the units are mililitres
                   Let Fluid Ounce = measurement*28.41
              else if the units are Pint
                   Let Litres = measurement*0.568
              else if the units are Quart
                   Let Litres = measurement*1.14
              else if the units are Gallon
                   let litres = measurement*4.54
              else if the unit are litres
                   let centilitres = measurement*100
              else
                   The units are wrong!
                   Print an error message and stop processing
              let mililitres = Fluid Ounce/28.4
              let Pint = Litres/0.568
              let Quart = Litre/1.14
              let Gallon = Litres/4.54
              let litre = centilitre/100
              dispay the results
              public void WeightConverter();{
                   Let measurement = TextIO.getDouble()
              Let units = TextIO.getlnword();
              if the units are Ounce
                   Let Ounce = measurement
              else if the units are Grammes
                   Let Ounce = measurement*28.35
              else if the units are Pound
                   Let kilograms = measurement*0.4536
              else if the units are Stone
                   Let Kilogrammes = measurement*6.3503
              else if the units are Longton
                   let metric tonne = measurement*1.016
              else if the unit are Gramme
                   let Killogram = measurement*100
              else
                   The units are wrong!
                   Print an error message and stop processing
              let Gramme = Ounce/28.35
              let Pound = Kilogram/0.4536
              let Stone = Killogrammes/6.3503
              let Longton = metrictonne/1.016
              let Gramme = Kilogram/100
              dispay the results
              private static void createAndShowGUI();{
                   ConvertValues newScreen = new ConvertValues();
         }

    My main problem is how to assign events to the button so that it preforms a calculation. [url http://java.sun.com/docs/books/tutorial/uiswing/components/button.html]How to Use Buttons
    Also, use the "Code Formatting Tags" when posting code so it retains its original formatting and is readable.

  • Can't get dupe checking working

    I'm currently making an inventory management system in java for college. The user enters a two letter combination (specified in a 2d array, the other side holds the full name for display purposes later). Now I also need to check whether or not the item number has already been entered. This is where I have a problem, it compiles fine but it just doesn't work at all. Here is the item number function, I know its something really small that I'm not seeing. Thanks for any help.
         public static void setItemNo()
              int index = 0;
              String item;
              error = true;
              do
                   //get item number
                   System.out.print("\n\t\tEnter an item number: ");
                   item = TextIO.getlnString();
                   item = item.toUpperCase();
                   //checking for duplicate entries
                   for (int dupeCheck = 0; dupeCheck == publicItemNumber.length; dupeCheck++)
                        if (item == publicItemNumber[dupeCheck])
                             System.out.print("\n\t\titem already entered");
                             dispmenu();
                   //item length not equal to 5
                   if (item.length() != 5)
                        //item length must be five, it isn't
                        System.out.print("\n\t\tPlease enter a vailid item number\n");
                        error = true;
                   //passed error check, item number is 5 chars!
                   else
                        error = false;
              }while(error == true);
              //now we check if the first two chars are actually letters
              found = false;
              String firstTwoCharacters = item.substring(0,2);
              while ((found == false) && (index < depts.length))
                   if (depts[index][0].equals(firstTwoCharacters))
                        found = true;
                        publicItemNumber[counter] = item;
                        return;
                   else if ((found == false) && (index < depts.length))
                        found = false;
                        index = index + 1;
              if (found == false)
                   System.out.print("\n\t\tPlease enter a valid number!\n\n");
                   return;
         }

    In this line:
    if (item == publicItemNumber[dupeCheck])Use ".equals" to compare the values. They are Strings. You do it correctly in the 'while' loop near the bottom.

Maybe you are looking for

  • XP Works Fine, Mac OS X Randomaly Black Screen

    Hey there, Macbook spes: White Macbook 2.2GHZ C2D Early 2008, 1.5Ghz, 120GB. Here's my Macbook story: The laptop had Leopard OS X 10.5.7 installed on it, when it started with randomly sleep/black screen - which sometimes I could wake the screen back

  • How to change the color of text highlight

    I'm trying to select and highlight certain text in the PDF. Here's my sample code. I want to change the color of the highlighted text. Something similar to what the Highlight Text tool does in acrobat. HiliteEntry hilite; hilite.offset = 10;  //Highl

  • "New Smart Object via copy" via JavaScript?

    I'd like to know how to copy a smart object but, so every smart object is independent. I know you can copy layers via layer.duplicate() but that function just copies a instance of the object instead of creating a new object. So how would you do it?

  • Oracle 11g - Objects Access ?

    Oracle 11g - Objects Access ? ===================== I hope this is the right forum for this issue, if not let me, where to go. We are using Oracle 11g (11.2.0.1.0) on (Platform : solaris[tm] oe (64-bit)), Sql Developer 3.0.04 We have a Schema A with

  • Declaring a table like another table

    Hello, I am trying to define another table, say itab, that has the same structure as, say, EDISEGSTRU so that I can use it in the function call: SEGMENTDEFINITION_READ as a parameter for Tables. May I know how can I declare the itab? Thanks a lot! Re