scanner

how to catch blank input with scanner class in java

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 blank lines are not caught as they should by the second conditional. For example when I press enter, this should be captured as a blank line and the second condi...

What's the difference between a parser and a scanner?

I already made a scanner, now I'm supposed to make a parser. What's the difference? ...

Does this program grammar only recognize variables with the name 'ID'?

I need to make a scanner in lex/flex to find tokens and a parser in yacc/bison to process those tokens based on the following grammar. When I was in the middle of making the scanner, it appeared to me that variables, functions, and arrays in this language can only have the name 'ID'. Am I misreading this yacc file? /* C-Minus BNF Gram...

Looping Forever

I'm trying to loop an exception, but for some reason its not giving me the option to re write my scanner file: I don't know how to use BufferedReader so that's why I'm using this. Any clues? Here's my standard class with my method package arrayExceptionsWithInput; import java.util.*; public class GetThoseNumbersBaby { int firstI...

Java: Infinite loop using Scanner in.hasNextInt()

Hi everyone, I am using the following code: while (invalidInput) { // ask the user to specify a number to update the times by System.out.print("Specify an integer between 0 and 5: "); if (in.hasNextInt()) { // get the update value updateValue = in.nextInt(); // check to see if it was within range if (updateV...

How to compensate for uneven illumination in a photograph of a printed page?

I am trying to teach my camera to be a scanner: I take pictures of printed text and then convert them to bitmaps (and then to djvu and OCR'ed). I need to compute a threshold for which pixels should be white and which black, but I'm stymied by uneven illumination. For example if the pixels in the center are dark enough, I'm likely to wi...

Why doesn't this for-loop let me input text the first cycle?

What I want to do is ask the user for a number of strings to read into an array, and then ask the user to input that number of strings and read them into the array. When I run this code it never asks me for an input the first cycle of the first for-loop, just prints out "String #0: String #1: " and then I can input text. Why is that and ...

Java server-client | server wont receive second request

I'm trying to write a client and time server for an assignment and I'm having trouble getting the server to receive the second request from the client. The first request goes through fine without a hitch. then it just stalls. I'm actually pretty lost in this whole thing and rather uncomfortable with java still, so I have no idea what I'm...

How do i input a string from a buffered reader?

Im used too using Scanner mainly and want too try using a buffered reader: heres what i have so far import java.util.*; import java.io.*; public class IceCreamCone { // variables String flavour; int numScoops; Scanner flavourIceCream = new Scanner(System.in); // constructor public IceCreamCone() { } // methods public String getFlavou...

Is there a mono (.Net) equivalent to the Scanner-class in Java

In Java there is a nice class called Scanner for reading strings and streams of a certain format to data-structures like integers, floats,... Is there any equivalent in Mono? In .Net there is a binary-reader, but it reads the data as binaries. I want a class that read the data by parsing it from a string. EDIT: reaction on the current a...

Extract Integer Part in String

What is the best way to extract the integer part of a string like Hello123 How do you get the 123 part. You can sort of hack it using Java's Scanner, is there a better way? ...

Reliably scan firewall for SIP ports?

To help customers troubleshoot VoIP, I was thinking of using www.nmap-online.com to scan their NAT router to check that their SIP client successfully punched the SIP/RTP ports open on their router. As a test, I used Nmap Online to scan my own PC which is behind a NAT router, but although UDP5060 was not used, nmap still reported it bein...

lex/yacc and parser/scanner

lex and yacc are supposed to be used together. Which ones is the scanner and which one is the parser? Which one creates a scanner and which one creates a parser? ...

How to find second largest number using Scanner and for loop(no array)

Hi.So I can easily accomplish task to find largest number and then if can be divided by three, print out. But do not know how to find second largest number from users sequence. Thanks for any hints! public class SecondLargest { public static void main(String[] args) { int max = 0; Scanner scan = new Scanner(System.i...

Using Scanner/Parser/Lexer for script collation

I'm working on a JavaScript collator/compositor implemented in Java. It works, but there has to be a better way to implement it and I think a Lexer may be the way forward, but I'm a little fuzzy. I've developed a meta syntax for the compositor which is a subset of the JavaScript language. As far as a typical JavaScript interpreter is c...

Java Scanner question

How do you set the delimiter for a scanner to either ; or new line? I tried: Scanner.useDelimiter(Pattern.compile("(\n)|;")); But it doesn't work. ...

PHP Uploads Limit for Scanning?

I read somewhere that the upload limit for php is about 2MBs. Does this still apply if I am asking a user to upload a file to the server to scan through and convert to a string? If so how do I get around this? The application for this is a scanner type deal where users would be able to upload a code file, and this php application would...

Cocoa ImageCaptureCore and scanner calibration

I'm successfully using ImageCaptureCore to scan and save images. However, if the scanner hasn't been calibrated by some other app, the resulting image quality is very poor. I've found that the ImageCapture libraries have no methods to automagically create and save calibration data for the scanner. How should scanner calibration be h...

How to scan a file in a different directory in java?

How do you scan a file with java that isn't in the directory the java file is in? For example: The java file is located at "C:\Files\JavaFiles\test.java" However, the file I want to scan is located at "C:\Data\DataPacket99\data.txt" Note: I've already tried putting another java file in the "C:\Data" directory and using the test.java fi...

Java InputStream != Readable

I am using java.util.Scanner for things such as nextInt(), and all was working fine as long as I was using a java.lang.Readable (one and only constructor argument). However, when I changed to using an InputStream instead, Scanner.nextInt() never returns. Do you know why? My implementation of the InputStream looks like this: private sta...