Scanner « API « Java I/O Q&A





1. Can I use Scanner class in text file for getting information?    stackoverflow.com

this code is correct??

String note = "text.txt";
FileWriter file = new FileWriter(note);
Scanner sc = new Scanner(System.in);
System.out.println("Enter your name:");
String name = sc.next();
file.close();
How can I pass this file to the program as a command ...

2. how to catch blank input with scanner class in java    stackoverflow.com

I am using the scanner class to capture user input from the command line (strings only), as an alternative to my previous question. The following seems to work fine, except the ...

3. Scanner vs. BufferedReader    stackoverflow.com

As far I know, the two most common methods of reading character-based data from a file in Java is using Scanner or BufferedReader. I also know that the BufferedReader read files ...

4. Java: Using the Scanner class to read input from a file without pipeing    stackoverflow.com

I currently have an implementation of a program where I read in the input using the Scanner class. Integer by integer. I do this by piping the input file via the command ...

5. Building a Scanner with an embedded FileReader recursively in java    stackoverflow.com

public static Scanner getFileScanner()
{
    try{
        Scanner input = new Scanner(System.in);
        String file = input.nextLine();
 ...

6. java.util.Scanner#findWithHorizon throws OutOfMemory exception on 32Mb input stream    stackoverflow.com

Search string '4914904' exists at the tail of the stream. Here's the code

    Scanner sc = new Scanner(xmlInputStream, "UTF-8");
   ...

7. Scanner.next() from a BufferedReader    stackoverflow.com

I am trying to scan text from a reader based on a delimiter "()()" by using the Scanner.next() method. Here is my code:

public static void main(String[] args)
{
    String ...

8. Java - Scanner not scanning after a certain number of lines    stackoverflow.com

I'm doing some relatively simple I/O in Java. I have a .txt files that I'm reading from using a Scanner and a .txt file I'm writing to using a BufferedWriter. ...

9. Reading a text file using BufferedReader and Scanner    stackoverflow.com

I need to read the first n lines of a text file as lines (each line may or may not contain whitespace). The remainder of the text file contains an unknown ...





10. Scanner vs. BufferedReader in terms of file reading    coderanch.com

I wasn't able to find a difference. Generally they're both limited by the speed of file access; other details are irrelevant as far as performance is concerned. You may discover one performs better than the other in certain situations, or maybe on certain platforms, but in general there's no significant performance difference. More importantly, Scanner has a lot more useful methods, ...

11. difference between FileReader and Scanner    coderanch.com

In j2se 1.4 version we have FileReader class to read the content of file. but comming to j2se1.5 we have new class called Scanner class which does the same thing. but i dont find any difference in their functionalities ??? :roll: can any one tell me the advantages and extra funtionalities of this Scanner class thanx in advance cinux

12. Scanner vs. BufferedReader/ InputStreamReader    coderanch.com

[Keith]: BufferedReader doesn't rely on breaking up its input into tokens. It allows you to read character by character if you want. It can read an entire line and let you do what you want. You can easily read a whole line with Scanner too, using nextLine(). It's also possible to read one character at a time with next() if you ...

13. FileReader or Scanner?    coderanch.com

Well, Scanner was in 1.5, so the proper question would be "who wants to use 1.4?" Reading through the posts here on JavaRanch, the answer is obviously "many people". As to why someone would use Java 1.5, well, not all operating systems have a released version of Java 6 yet, OS X being the most prominent one.

14. Two scanner FileReader    coderanch.com

I am able to compile my code but for some reason when I try to run my program nothing happens and I narrowed it down to the second scanner filereader that i need to read in data from a second file and create a customerList. I made it exactly the same as the first one so I don't know what i'm ...

15. Difference between FileReader and Scanner    java-forums.org

16. cannot find symbol: method Scanner(java.io.InputStream)    java-forums.org

G'day everyone I am just beginning a university course in programming and I previously have no experience with it. It's only an introduction course so not difficult to pick up, however I am having a problem compiling a simple program designed to calculate the area and perimeter of a rectangle after receiving input from the user (height and length values). The ...





17. Scanner overriding output stream    java-forums.org

*DO NOT BE DISCOURAGED TO READ DUE TO LENGTH; IT IS QUICKER TO READ THAN YOU THINK* My issue is that I cannot get my output stream to look and work the way I intend and I think its to do with the scanner class. I am creating a program for users to enter the hours they have worked at their ...

19. Datainputstream and Scanner    forums.oracle.com

20. Using Scanner and FileReader to read from a file in real time    forums.oracle.com

Hi I would like to read continually from a text file (which is continually being appended to) and display each line as it appears in the textfile (in a text area). What I would like to know is do I have to continually reopen the file (using FileReader) and buffer it into a Scanner everytime I want to read the changes ...

21. OT: BufferedReader vs. Scanner General Question.    forums.oracle.com

Hi everyone. First let me say I have not googled or searched the forums for this type of question. I am most interested with answers from those of you working in the field. I have been posting, and hopefully helping users, since March or so and I see many posts using the Scanner class. Most questions seem come from very green ...

22. Scanner & PrintStream Issue    forums.oracle.com

I am trying to create a order form in a GUI and cannot get the program to read inputed data from the keyboard and than print the data to a file. My first attempt the program compiled, but when the submit button is clicked I get the error "Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not Implemented!". My second attempt at the program ...

23. new Scanner or PrintStream - exception must be caught    forums.oracle.com

T.Todd wrote: Hi, I've been taking java classes at my school for a little while and now that it's holiday Where is it now a holiday? And what's the holiday? As I wrote it I discovered I can put static String file = "FirstWrite.txt" and static toDisk currentFile = new toDisk() at the beginning of the class so I don't have ...

24. File Chooser and Scanner/ PrintWriter    forums.oracle.com