-1
votes
0answers
10 views

How do I search a string for a keyword, then print whatever comes after that keyword in java?

I want to search a string for a specific word and then print the next 5 characters after that word. I have no idea how to go about this. I have tried searching for tutorials but could not find ...
0
votes
7answers
48 views

Is there a better way to traverse a string in java?

Please bear with me. I haven't programmed in over a year and I'm currently reviewing my Java for job interviews by doing "homework questions." My function is supposed to return a string containing ...
-3
votes
3answers
68 views

how to check if a string is of the form dd-mm-yy

I'm trying to test on a String, if it is of the form dd-mm-yyyy. Any help please? Sorry, i'm just a beginner.
1
vote
5answers
53 views

Create a new array index if it doesn't exist

Say I have a String like below String s1 = "test1=1&test2=2&test3=&test4=4"; Pls note the test3 parameter in the string S1 as it doesn't have any value String [] splitS1 = ...
1
vote
6answers
55 views

Empty String Validation

I've read through this SO thread: How to check whether a string is not null & empty? The question that arises (and was not answered in that thread), is: Why is string.isEmpty() better than using ...
1
vote
2answers
59 views

Convert binary string to byte array

I have a string of ones and zeros that I want to convert to an array of bytes. For example String b = "0110100001101001" How can I convert this to a byte[] of length 2?
0
votes
0answers
32 views

How can I make a String buffer in the form of a table

I am working on report application in which contact information need to be shown on page header such that if information is more it appears on next column right aligned like a table. For eg:- Suppose ...
0
votes
1answer
62 views

Java parsing double to string

i have got such part of the code: double double1 = 0.000112344; String string1 = "0.000112344"; System.out.println(String.valueOf(double1) + " : "+string1); results: 1.12344E-4 : 0.000112344 The ...
-1
votes
2answers
47 views

javascript: String to Byte[] to String [on hold]

I coded my application in java in a first time and I should now coded it in javascript and I have some problems in the handling of string and arraybytes in javascript and recoding methods of ...
-1
votes
0answers
75 views

string to 94 byte string in java [on hold]

Can any one please help how to convert String to 94 byte String in java. If I have a String str ="7YoOZeZm7Wd0PBCPsYEsA9GywHZgUWGS68M5EbAsc6gmUoIKUpd5SCepv383Cdks83uZpaoP9H"; how can we convert ...
2
votes
5answers
90 views

Java Immutable Objects

I am learning the concept of immutability. I understand that immutable objects cannot change their values once the object is created. But I didn't understand the following uses of immutable objects. ...
1
vote
2answers
52 views

RegEx - Java - Matching Strings (012|123|234|345|456|567|678|789|890)

I am working on password enhancement and client wants a password that does not have consecutive letters ie: 123, 234. I have figured out that you can declare strings that you want to match in regex ...
1
vote
3answers
59 views

Retrieving integers from a string

Say you have a string: String numbers = "123 11 4392034 2"; and you want to retrieve each integer in the string (separated by spaces). What is the best way to go about doing this?
-8
votes
4answers
72 views

java splitting textboxes using bufferreader [on hold]

Hi I am figuring out how to split the strings so heres my code: because i using bufferedreader and i have two textboxes so it reads both the text boxes (the 1st textbox i type john), the second ...
-4
votes
3answers
50 views

Refer to an object by using a name in a string android

I want to be able to use an object in java by using names stored in variables. For example : String[] str={"name1","name2"}; Button name1 = (Button) findViewById(R.id.but1); Button name2 = (Button) ...
0
votes
3answers
127 views

A well formed java string [on hold]

A friend had an interview question asking the following: Given a string comprising of the characters (,),{,},[,], determine if is well formed or not. In my mind I would have answered no as it is ...
-1
votes
4answers
62 views

How to get a substring from a string [on hold]

I have this xml file from where I'm reading this string, http://localhost:8080/sdpapi/request/10/notes/611/ My question is how can I get just the 611, which is of variable, can be 100000, for ...
0
votes
3answers
29 views

Split line with with several spaces

I have a text file in which I have to take line by line. for each line I have to cut my string and put it in a table. My separator is space. Example of String: 22/03/2013 00h00 9940 10200 ...
0
votes
6answers
52 views

String as an object in pool or as a reference?

I'm a little confused on what does string pool actually contain. When we say String s = "abc", does this mean that during compile time, the string object is put in the string pool or is it the ...
0
votes
1answer
24 views

Why does JSONTokener/Object keep randomizing my json data?

I've been trying to debug this problem for hours and have Googled it and can't even find someone who's having the same problem. For some reason JSONObject/JSONTokener is doing bizarre things. The ...
5
votes
1answer
91 views

Is String.hashCode() inefficient? [on hold]

When looking at the source code of java.lang.String of openjdk-1.6, i saw that String.hashCode() uses 31 as prime number and computes s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] Now the reason ...
0
votes
2answers
61 views

Find xml-tag that is not closed in java

I'v the following string: <table:table-cell table:style-name="Table2.A1" office:value-type="string"> <text:p text:style-name="P32"> <text:span text:style-name="T1">test ...
0
votes
4answers
48 views

StringIndexOutOfBoundsException String index out of range: 0

I am writing a program that opens a text file and checks for comments. It then parses through the comments to check for certain words. The error im having is with the following while loop that checks ...
1
vote
3answers
44 views

Does String objects created differ due to char[] and compile time resolution?

There are many questions on this in many forums but when you read every one of them, you actually go back to where you started!! As far as I've understood, for the example below: 1. String s = ...
0
votes
3answers
39 views

compareTo() giving conflicting results in a client/server application?

Hello everyone: I'm having a very weird issue with a simple multithreaded server/client app. I currently have two running hosts which runs say, Client 1 and Server 1, and another which runs C2 and S2. ...
0
votes
4answers
34 views

Regex in java to find if a String is in the format of a decimal number with a trailing zero

I am reading a list of Strings, some of which are in the form of decimals and comapring them against another. Sadly, in the first list, I find that all decimal terms aka all the strings have an extra ...
0
votes
2answers
59 views

Do integers occupy less space as keys in a java HashMap compared to strings?

Let's say I have a HashMap<String, Integer> with keys being words and values being their frequency in a corpus. Does it save memory to replace words with some integer (e.g. "hello" is ...
0
votes
6answers
45 views

Cut Java String at a number of character

I would like to cut a Java String when this String length is > 50, and add "..." at the end of the string. Example : I have the following Java String : String str = "abcdefghijklmnopqrtuvwxyz"; I ...
-1
votes
2answers
62 views

Cannot view my string [on hold]

I am attempting to call a method in my main and have it viewed in a tabular form. The headings of the form display fine but the actual contents of the table do not appear. Here is the code I'm using - ...
1
vote
3answers
82 views

converting all possible string dates to date objects

I need to be able to convert all possible string representations of a date to a Date object. I know that this is not a trivial task and I mainly ask for guidance, as I believe there is no 'one-liner' ...

1 2 3 4 5 254
15 30 50 per page