Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: File structure

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Location
    Butuan city
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default File structure

    import java.io.*;
    import java.util.Scanner;

    public class AdvExerProg1 {
    static String studentList[];
    static int studCount;
    static Scanner s = new Scanner(System.in);
    public static void main(String args[])throws IOException{
    char ops ='N';
    char save='Y';
    String File="student.txt";
    String Lastname,Firstname,Record= "";
    String Rec =":";
    boolean quit =false;
    boolean done = false;
    int record=0;

    FileWriter txtFile =new FileWriter(File,true);
    BufferedWriter studFile = new BufferedWriter(txtFile);
    studentList = new String[5];
    studCount = 0;

    studentList = new String[5];
    studCount = 0;
    do{
    record ++;
    Record =Rec+record;
    System.out.print("Record"+Record+"\n");
    System.out.println("---------------------------------------");
    System.out.print("Enter Student FirstName:");
    Firstname=s.next();
    System.out.print("Enter Students Lastname:");
    Lastname=s.next();

    Record = Lastname +", "+Firstname;
    studentList[studCount]=Record;
    studFile.write(Record);
    studFile.newLine();
    studCount ++;

    z

    if(ops==confirmYesNo("Another Student?"))
    done =true;

    }while (!done);

    if(studCount!=0){
    System.out.print("--------List of "+studCount+"Students---------\n");
    for(int n=0;n<studCount;n++){
    System.out.println(studentList[n]);
    }
    }
    System.out.print("Press any key to continue:");
    ReadChar();
    System.out.print("bye bye !!!!");
    System.exit(0);
    }

    public static char ReadChar(){
    String data;
    char chr;

    data=s.next();
    data=data.toUpperCase();
    data=data.trim();
    chr=data.charAt(0);

    return chr;
    }



    public static char confirmYesNo(String msg){
    char opt='n';
    do{

    System.out.print("\n"+msg+"[Y/N]->");
    opt = ReadChar();

    }while(opt!= 'Y' && opt !='N');
    return opt;
    }

    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: File structure

    Did you have a question?

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 8
    Last Post: December 4th, 2012, 04:58 AM
  2. Structure
    By Gerardgrundy in forum Object Oriented Programming
    Replies: 8
    Last Post: November 3rd, 2012, 02:25 AM
  3. Re: Data Structure
    By jim17 in forum Object Oriented Programming
    Replies: 3
    Last Post: November 16th, 2011, 11:14 PM
  4. HI can some one tell me the size of the below structure.
    By sucheth13 in forum Java Native Interface
    Replies: 1
    Last Post: March 11th, 2011, 03:08 AM