help with I/0 with prompt
Hello everyone.
I need some help here.
I can not figure out where to put my .txt info at.
I 'm trying to use my instructure, some what confused. I have also read the info form Java and they really don't give an example on how to use a scanner and where to plac the .txt.
here is my code so far
publicclass Reading{
publicstaticvoid main(String[] args)throws Exception{
Scanner kbd =new Scanner(System.in);
int choice;
System.out.println("Make a Section: ");
System.out.println("1. Read Text File ");
System.out.println("2. Copy Text File ");
System.out.println("3. Exit ");
System.out.print("\nPlease press Enter afer each response");
System.out.println("Enter your choose please: ");
choice = kbd.nextInt();
kbd.nextLine();
if (choice == 1){// if 1 is select go to makePerson
String fname;
FileInputStream fin;
long datalen=0;
Scanner kbd1 =new Scanner(System.in);
System.out.println("Enter file name");
fname = kbd1.next();
kbd1.nextLine();
fin =new FileInputStream("c:\\data.in");//
while( fin.read()!=-1){
datalen++;
}
System.out.println("File "+fname+" is "+datalen+" bytes long");
}
}
thanks
sandyR
PS is this code right.
It needs to find the .txt then open the file and display the contents. Do I need to use PrintWriter or can I use Printf(fname)
Message was edited by:
SandyRed

