find « string « Java Data Type Q&A

1. What is the best way to find specific tokens in a string (in Java)?

I have a string with markup in it which I need to find using Java. eg.

string = abc<B>def</B>ghi<B>j</B>kl

desired output..

segment [n] = start, end

segment [1] = 4, 6
segment [2] = 10, 10

2. Java error: can't find symbol?

I have the following code snippet where some strings are initialized in the if block:

String serialmask = request.getParameter( "serialmask"); 
String serialincrement = request.getParameter( "serialincrement");
if (serialmask == "1") { 
  String ...

3. How to find all naive ("+" based) string concatenations in large Java codebase?

We have a huge code base and we suspect that there are quite a few "+" based string concats in the code that might benefit from the use of StringBuilder/StringBuffer. Is ...

4. Finding tokens in a Java String

Is there a nice way to extract tokens that start with a pre-defined string and end with a pre-defined string? For example, let's say the starting string is "[" and the ending ...

5. Java best way for string find and replace?

I'm looking for the best approach for string find and replace in Java. This is a sentence: "My name is Milan, people know me as Milan Vasic". I want to replace the ...

6. Java: Finding birthdate on different planets

I'm writing a program that asks the user for their birthdate and then calculates that birthdate on different planets. I am not suppose to assume how the birthdate is to be ...

7. Java: "cannot find symbol" error of a String[] defined within a while-loop

Here's the relevant code:

public static String[] runTeams (String CPUcolor) 
    boolean z = false ; 
    //String[] a = new String[6] ; ...

8. Finding a / symbol in string

I'm trying to find a forward slash in a string... This doesn't seem to work:

if ("/test".indexOf("/") > -1) {
What am I doing wrong? Funny thing is... I tried this:
if ("!test".indexOf("!") > -1) {
and ...

9. Finding the signs from a string Java

Is there a function or something, that is made for finding the signs in a String (e.g. +/-[]{})(). If there is such a thing, please tell or if not, just to ...

10. Java find a string in text not working

This is a sample .txt file:

I created a class to find a string in a .txt file:
public static String lineToFind;
public static boolean lineFound;
public static void findLine() throws IOException{

11. Cannot find variable charAt() ERROR

Ia m getting the following error while running my SIMPLE java program [ I guess!!! ], please HELP as this will lead me to make a bigger module[ mean that i ...

12. find and replace strings

I am trying to find and replace strings. Below is what I have sofar. I am troubled on how to force all the changes to show in one line as showed ...

13. How to find a string which is case-sensitive and ignore it in JAVA

I have a text file (T1.txt) in which it has few strings.out of them 2 are similar but case-sensitive. I have to ignore the other one and get the rest of ...

14. Java - find in string and start from the right

Maybe I am making this too complicated but I think I need to start reading a string from the right to find its position. Here is my sample:

In this string I ...

15. How to find circular dependency of a string using Java

If I have 2 files say ABCD.txt and DEF.txt. I need to check if the String "ABCD" is present in DEF.txt and also the string "DEF" present in ABCD.txt and write ...

16. Using String to find Class in java?

I have made a class named Entity, and have the following code:

Entity zombie1 = new Entity();
I get input 'zombie' from a scanner, and then concatenate a number, based on level on ...

17. how to find frequency of a phrase (multiple token string) inside a document in java?

I want to find the frequency of a multiple-token-string or phrase inside a document. Its not the word/single-term frequency that I am looking for, its always will be multiple-term and the ...

18. How to find EOF in a string in java?

I am working in school project. In that what they told is, I will be given a String which contains an actual program like....

import*\npublic class A{\n...........EOF
And My job ...

19. cannot find symbol method d(java.lang.String,java.lang.String)

When I compile the code below error occurs:

canot find symbol
 location: interface org.apache.commons.logging.Log    Log.d(TAG,"JSON parsing error - fix it:" + e.getMessage());`
This is my code:

private void convertJSONtoArray(String rawJSON){

20. Where can I find detailed info regarding Twitter4J Query strings?

Hi I have this project that I need to use Java to access twitter api, and I found Twitter4j easy to use and tried some samples from the site. However I ...

21. Find hard-coded password strings in project's code - Can it be done automatically?

Hey, I have a very big project with thousands and thousands of code lines. Until now we have used hard-coded passwords and we wish to stop. The problem is how detect ...

22. Where can I find 'POST' Request String?

23. to find the datatype of given string in runtime

I think a common convention in this type of situation is to define what the "data type" is. That is you get each field one at a time in a pre-defined order. Then you can use the various tools available to convert it into the internal representation you wish to use. For example, when you expect an int, you can use ...

24. Finding string occurrences in a string

Hey guys, I am looking for a specific occurrence of a string in a larger string. Now im aware that the method Sting.indexOf(occurrence) will return the integer position of the first occurrence of the string im looking for, but i know that the string im looking for appears more than once in the larger string and i would like to find ...

25. finding hardcoded string

26. Find String Within a String

27. find a String

28. newbee cant find string

29. does java have a class to find string width?

Does anyone have any suggestions on what I could do to figure out the width of a string? Ex: If I have two strings: "WHOOO HOOO" vs "ITTY BITTY" Both strings have the same number of letters however when I use a font that is not fixed width - then the second string takes up less room when typed. Is there ...

31. finding a sequence in the string

32. Looking for utility program find strings..

I think what Henry is getting at is this: A simple search for a particular string -which happens to be a procedure name- might not be sufficient, since that string could also be part of a comment. So in the worst case, you'd have to have an actual parser for whatever syntax those file contain, in order to distinguish proper occurrences ...

33. finding combinations of string

Are you asking how to determine mathematically the number of different combinations of letters, given a particular string? I may very well be wrong, but isn't it the number of characters factorial? Say you had 5 characters, 5! equals 120. There are 120 different possible ways to rearrange the characters. Or take the sequence "123". 3 characters, so 3! equals 6: ...

34. Finding diff between two string

35. finding phrases in a String

36. cannot find symbol inside String?

I have building this program that works with exception handlers, while I believe I have it down pretty good, I am getting one type of error that I am not sure about. .\ ';' expected System.out.print('please enter a valid input: '); ^ .\ unclosed character literal System.out.print('please enter a valid input: '); ^ .\ cannot find symbol symbol : class enter ...

38. how to find all possible combinations of charcters in string

hi all , this the example , i have a string contains 4 chars (A,B,C,D). size =4 , now all possibel cimbinations = N! which N = length of the String i want to find all possible combinations like ABCD ABDC ACBD ACDB ADCB ADBC BACD BADC BCAD BCDA BDAC BDCA AND etc ...... till we reached to N! .

39. Find the lowest string using Java

41. Finding Most Common Phrase Occurance In String?

Hey guys, this is an interesting problem. Let's say I have a string like this: String s1 = "My name is Justin and I love writing code and writing about coding algorithms." +" In fact, some of my best days are created by working with coding algorithms." +" Even though I can't say for sure how much I truly love writing ...

42. Finding exact element in String

Hello, I have a string strCurrentTableRow which contains xxxxxxxxxCD01xxCD01(A)xxxxxxxxAB01xxxxxxxxxxxAB01(A)xxxxxxxxx where x is any character and the position of AB01 can change anywhere. Now, I'm using a variable strCurrentRequiredJf which will have either AB01 or AB01(A), which will be dynamic, meaning it can be CD01 or CD01(A) as well based on the stuff selected by the end user. I have an IF ...

43. cannot find symbol method getResponseHeader(java.lang.String,java.lang.String)

Hi friends, I have the following code. When I execute it is throwing this Error "cannot find symbol method getResponseHeader".. Can you Please help me to solve this Error. I have pointed all the below jar files but still Error exists. commons-httpclient-3.0.1.jar commons-httpclient.jar commons-httpclient-3.1-rc1.jar httpclient-4.1.1.jar org.apche.commons.httpclient.jar Code:- public class try2 { private static String nameSpaceID = "cogndvldap"; private static String userName ...

45. this is the error i get: cannot find symbol method parseString(java.lang.String)

this is the question and my code Hilan International Bank decided to have a salary plan for its employees. In the new Policy, bonus is based on the fact that one is a senior staff or junior staff. You have been called in as a programmer to develop a software to meet this policys requirement: (a.) Create a class called Salary. ...

46. Find a string within a string

Hi, I have a string A= "Amsterdam" There is another string B= "amst" How do I find if String A contains B. I tried using the contains method but that is case sensitive. I also tried StringA.indexOf(StringB)>0 but this does not work if String A has a uppercase 'A' and string B with lowercase a. If String B="amst" or "Amst"(with uppercase) ...

47. Help with finding digits within string

48. cannot find symbol string

Can I just point out that those comments in your code are completely worthless. Might sound like a nitpick, but if you're not thinking about whether your comments make sense, chances are you're not thinking about whether your code does, either. Anyways, Encephalopathic seems to have a handle on your problem, but just slow down and think about what you're trying ...

49. Finding string in a textpane

Did you see my last post? Did it stimulate you do do anything new? You know that your search is based on the carot position, correct? If the carot position isn't changed, you will continue to search based on the same spot in the string. Do you think that there may be anything in the JTextPane api (or one of it's ...

50. Finding a string inside a document.

First, learn what code tags are and how to use them on computer programming forums Then, figure out how to read in a line of data from the file into a String variable. Then look through the definition of java's String class for methods that will allow you to search the String variable for a given piece of text. Repeat for ...

52. Finding first numeric in string

GaryJSF wrote: Thanks so much. I implemented the array solution and it seems to work but I am still testing it. Is there any advantaged to using the regex solution? Which one is better java standards? Since you put it that way, the array solution is better: it's pure Java, and completely transparent. You don't even need to know Java to ...

53. Find the nth occurrence of a string in a string

Hi, thank you for all your tips/hints/code. @calypso : What I don't understand in your code is the global 'count' variable. I simply don't get the picture (sorry). Another question: you're talking about that s'.indexOf('toFind', 'index'+1) would shorten the code. What do I have to replace Cheers Jonny Edited by: jonnybecker on Jan 14, 2009 12:02 PM

54. How to find the start of xx-xx-xx-xx in String

You might want to start by describing precisely what you want to match. If you can't describe it precisely to the forum in English, nobody will be able to help you describe it precisely to Java in regex. Also, when you post code, use code tags so it will be readable and not turn various characters into markup. When not in ...

56. Finding certain parts of a String.

{code} RuneScape - the massive online adventure game by Jagex Ltd.