Tagged Questions
6
votes
1answer
57 views
How to efficiently parse HTML table using jsoup?
I am trying to parse HTML using "jsoup". This is my first time working with "jsoup" and I read some tutorial on it as well.
Below is my HTML table, which I am trying to parse.
If you see my table, ...
3
votes
2answers
99 views
Parsing arithmetic expressions like (x + y * a + b *z)
I have this code which I wrote to parse arithmetic expressions.
However, many people say there are problems with it but don't tell me what the problem is. Please let me know if you see any.
Note ...
7
votes
2answers
362 views
Optimizing this inefficient TicTacToe configuration parser
On a programming contest I came upon this question:
Given a partially played 3 × 3 tic-tac-toe configuration, write a program to determine which player will have a better chance of winning if the ...
3
votes
1answer
92 views
Parsing version number from a Java source file
I'm extracting the version number from a file like this one. It works, but I find it clumsy and longer than probably needed.
I'd also appreciate some sanity checks as long as they don't make the code ...
3
votes
1answer
45 views
Stripping out all /* */ comments from a paragraph
I've written this code keeping the following cases in mind and I think I've covered them all. I'd really appreciate if someone could help me determine if I've covered all of them.
Cases I considered:
...
3
votes
2answers
52 views
How can I speed up my RSS feed Android App?
I have a problem with parsing RSS from a PHP page because the app is too slow.
This is my parsing code:
...
3
votes
3answers
680 views
6
votes
1answer
83 views
Extraction of data from Flickr
I'm crawling Flickr for data for my university research project. However it's very slow and I'm not sure what it is exactly. It could be the FileWriter slowing it ...
7
votes
2answers
387 views
Parsing CSV file with BufferedReader vs Scanner
I have to parse file line by line and in single line I have split by ",".
First String would be Name and Second would be count. Finaly I have to display the Key and Count
For example
...
4
votes
1answer
123 views
Library for parsing strings to java types, generic types and collections/arrays
I've done a library that can parse strings to different java types and to List<...>, Set<...>, ...
8
votes
2answers
404 views
Object Creation during loops
I'm trying to parse a CSV file into objects. I've already got a very efficient CSV parser (SuperCSV). The problem arises when trying to create the object with the data that is being read out.
I've ...
9
votes
2answers
889 views
Math expression solver
Recently I've stumbled upon an interesting challenge for me.
You should develop C application, that solves math expressions. Operations such as (+,-,*,/) should be supported, as well as (cos, sin, ...
4
votes
2answers
268 views
Numeric expression parser - calculator
In particular, if someone could describe a better way to go from the tokenized list to the Expression tree, it would be super helpful. I would like to get rid of the casting in the parser but am not ...
6
votes
2answers
4k views
Read an input text file and store the tokens in 2 different arrays
I am very new to Java so please ignore if there are obvious mistakes. If my question seems redundant then please guide me towards the correct link. However, I have surfed enough in order to find the ...
2
votes
2answers
2k views
Android AsyncTask, HTTP Request and Parsing
I am working on Android applications for last 2 years and about 80% applications I have developed involve web-services consumption followed by some sort of XML or JSON parsing. Initially, when I had ...
7
votes
1answer
324 views
HTTP Authorization header parser
I'm writing a parser for HTTP Authorization header (see RFC2616#14.8 and RFC2617#1.2). Note that I explicitly don't care about the base64-encoded syntax used by HTTP Basic authentication. I'm only ...
6
votes
1answer
290 views
Speed up CSV reading code (vector of doubles)
I am trying to read a single-columned CSV of doubles into Java with a string header. It is 11 megabytes and takes over 15 minutes to read, which is clearly ...
3
votes
1answer
104 views
Reading and validating 2D matrix bar code
I need a review on this. This code will read a 2D matrix bar code, which I hard-coded as a string str. It has "]d" starting string, which is a GS1 International ...
42
votes
11answers
9k views
Nesting versus GOTO: which is better to avoid?
In Java they're not really known as GOTO statements and are rather referred to as Branching Statements, but I find that the former term is a bit more indicative of ...
7
votes
2answers
421 views
Digit to words converter
This is one of the longest programs I have made with methods and I think I must be doing this rather inefficiently. Any comments to improve would be appreciated.
...
5
votes
1answer
116 views
How to efficiently parse the data coming from the URL?
I need to parse the data coming from the URL which looks like below -
...
8
votes
1answer
2k views
A boolean expression parser, written in Java
I was trying to write some of the Haskell list functions into Java, and I realized that one of the key strengths for many of the functions was the ability to pass in a boolean expression. I decided to ...
4
votes
2answers
1k views
Optimize parsing of number for currency conversion
I have written this block its working fine but is it optimized? I am getting currency in format 1.234,25 .
...
3
votes
1answer
2k views
Simplifying HTML parsing
I'm working on an app for my school (not homework, an app that's going to be used by students), that's supposed to display our week schedules. I get the data from a webapp, but it has no API that I ...
5
votes
1answer
1k views
Parse strings and convert the value to .java types
Below is a generic code for parsing strings (read from file for example) and converting them to .java types, such as primitives (and their wrappers), java.io.File, Enum etc. There is also possible to ...
7
votes
2answers
143 views
Hello Java World ~> Parsing a Sudoku Grid
This is my first, very-very first attempt at java. I haven't started tackling the actual resolution of the sudoku puzzle (not even sure where to start, haven't looked at other weekend-challenge ...
7
votes
4answers
190 views
Looping Strategy: Change behaviour after first iteration
I have often encountered the following situation. I want to call a method in a Loop, but want to skip the call at the first run. It do not have to be a method, it also can be some lines of code that I ...
2
votes
1answer
248 views
Very basic Context Free Grammar in Java
I wrote this program for an assignment, thus I had some requirements as far as the format of the cfg.txt file and some basic other classes that we had to use. Other than that, I am curious if there is ...
-2
votes
1answer
42 views
Listing daemons from Linux [closed]
I have this code that lists daemons from Linux. I use /proc filesystem to get the data that I want to read:
This is the file structure:
...
4
votes
1answer
244 views
Regex parser - request for review and optimization
The whole question is Better implementation of a simplified regular expression engine?.
I have solved the question, and in turn felt the need to get it reviewed. Any suggestions for clean up and ...
2
votes
2answers
129 views
Retrieving doubles from string - simple problem
The problem is not very complicated (I mean it is easy to solve it), but the question is how to make it in the easiest way (Java)
Input String:
...
2
votes
2answers
164 views
DOM parser implemented from scratch
I have implemented a DOM parser. I would like any comments for optimizing, improving, and making the code coherent to best coding practices.
...
5
votes
1answer
292 views
Can I get some tips for improving my tokenizer design?
I need some tips on how to improve the design of the following code. Everything works correctly in the program. It takes a string and shows each token the only tokens being numbers and operators. The ...
3
votes
1answer
335 views
1
vote
1answer
108 views
Style Check and Boundary Condition Handling - KMP Pattern Array Generation [closed]
I am trying to implement the pattern encoding array that KMP uses to determine the number of positions the pattern should move in the text to augment the performance of a Naive Pattern search.The code ...
2
votes
2answers
131 views
Using annotations to keep code maintainable
https://github.com/ElgarL/TownyChat/blob/582796e43a0c3b0828c8a5655e8d693bfed94c00/src/com/palmergames/bukkit/TownyChat/TownyChatFormatter.java
From above:
...
1
vote
1answer
974 views
A better approach to parsing this file name in Java?
I am creating a file uploader, and one function of the uploader will parse the file name to make sure that it is in the correct format.
This is the proper format of the file name: ...
8
votes
1answer
178 views
Locale-related code — are there corner cases I didn't see?
This is a utility class I have in one of my projects and I seek feedback on it. I have read the javadoc for Locale quite a few times while developing this code. I ...
3
votes
2answers
5k views
Better way to get the XML attribute value?
I have an xml file from which I want to extract the value of attribute custName from the very first child. The code below works where I am using the dom parser. Is ...
1
vote
3answers
1k views
How should I read coordinates from a text file?
I have a text file with lines that look like this:
...
3
votes
2answers
2k views
Custom parser for named parameters in prepared statement
I'm creating a small extension to the JDBC API, with the hope of automating some common tasks and avoid boilerplate code.
One of its features will be a basic support for named parameters in prepared ...
1
vote
2answers
142 views
Can you guys look at my java project and give me some tips?
So I feel like I'm a good coder, but that's from my point of view. Can you take a look at my code and give me some tips or criticize me on my code. Or give me some tips or things to add or make things ...
2
votes
3answers
2k views
Parse an XML file using objects / methods
So I spent a while this morning creating an xml parser in java which is part of a job interview. I would love to have some people tear it apart so I can learn from any mistakes that I made so I can ...
3
votes
1answer
10k views
Optimize JSON insertion to SQLite (insert … on duplicate key ignore)
In current task, I'm refactoring the code of converting JSON file into SQLite database on Android device. Code compliant with Java 6.
As a benchmark, grabbing the code from remote server takes ...
2
votes
1answer
154 views
Game level parser
The code for the LevelParser is shown below. It is also documented using Java-doc; the docs are in the project directory.
Now by improving this piece of code, I do ...
7
votes
1answer
906 views
Parse Java source code
I have a bunch of simple interfaces like this one (pretty enough formed, but not guarantee)
...
5
votes
2answers
536 views
Code review - parse a query to arrays
I have a query like this "abc=1, def=2, ghi=3" and I need to parse it into arrays like this ...
10
votes
4answers
9k views
Simplify splitting a String into alpha and numeric parts
Requirement: Parse a String into chunks of numeric characters and alpha characters. Alpha characters should be separated from the numeric, other characters should be ignored.
Example Data:
Input ...
7
votes
2answers
497 views
Are there any ways to improve my HTTP request path parser?
I have written a method to tokenize HTTP request paths such as /employee/23/edit.
...