0
votes
1answer
28 views

word replacement within a string

I need help creating a loop which will return a string, replacing the words in it that are surrounded by hashmarks by using predefined operations. These include getRandomElement, getPhrases, and ...
1
vote
2answers
26 views

Alternate CodingBat sumNumbers exercise solution

I was trying to get around the below problem in codingBat for Java: http://codingbat.com/prob/p121193 Given a string, return the sum of the numbers appearing in the string, ignoring all other ...
0
votes
1answer
43 views

Need help to split in Java

I have this problem in java. When I write 3/5 + 3 it returns 18/5 and it's correct but if I write 3/5/ + 3 it returns 18/5 instead of error public static RatNum parse(String s) { int x = 0; ...
-4
votes
0answers
28 views

Delimiting a string in java [on hold]

I have a string stored in this kind of format in the database: "VALUE_G=9000","VALUE_S=ABC","VALUE_B=XYZ","VALUE_A=10"; or "VALUE_A=70","VALUE_S=ABC","VALUE_B=XYZ","VALUE_G=1000"; etc., I need ...
1
vote
3answers
29 views

String newline split from file

a.txt : 1,2,3 1,2,6 2,4,5 Reading and splitting String wynik = readFileAsString("a.txt"); String[] wyniki = wynik.split(""); I can't seem to find a way to split String out after newLines that ...
1
vote
2answers
44 views

Need help transforming code to work with strings rather than integers

In an older post, I asked for help with this problem: Given a StringBuilder of a text file with formatting A [1, 2, 3, 4] B [5, 6, 7, 8] C [9, 10] I need to create a method so that when given the ...
0
votes
3answers
51 views

Cannot replace strings [duplicate]

I am reading the iptables log output directly from the console and I need to clear the results a little bit. Currently I am getting: SRC=192.168.1.1 PROTO=UDP DPT=12638 SRC=192.168.1.1 PROTO=UDP ...
1
vote
5answers
32 views

Loop isn't breaking when a specific string is inputted [duplicate]

When the user inputs pBreak, it should break the while loop. However, this isn't working and I'm confused on why. Could somebody please help me? package main; import java.io.*; import java.util.*; ...
0
votes
2answers
44 views

Trying to use “setVariable”

Trying to use setVaraible() to make the String "Hometown" equal user input, so it can be called back later. Someone else previously helped me with something of this nature, but it was used in a loop, ...
1
vote
2answers
26 views

Appending Strings vs appending chars in Java

I am trying to solve an algorithmic task where speed is of primary importance. In the algorithm, I am using a DFS search in a graph and in every step, I add a char and a String. I am not sure whether ...
-5
votes
1answer
33 views

string.remove isn't working for me [on hold]

Public void example(){ while(w.size()>0){ Scanner sc = new Scanner(System.in); String word = sc.next(); if(word.length()<=2){ //I want to put word.remove() ...
0
votes
0answers
46 views

Most efficient way to remove invalid URL characters? [on hold]

I have a special use case where in a certain website I want to access truncated invalid url characters instead of encoding it when it generates URLs. I could loop through the whole string to make ...
6
votes
5answers
67 views

Correct way to trim a string in Java

In Java, I am doing this to trim a string: String input = " some Thing "; System.out.println("before->>"+input+"<<-"); input = input.trim(); ...
0
votes
5answers
48 views

Java - Check if a string only contains certain characters (i.e. DNA/RNA)

I'm struggling with regex. I want to make something like this: if (sequence.matches(A|T|G|C)){ String type = "DNA" } elseif (sequence.matches(A|U|G|C)){ String type = "RNA" } so that the type is ...
1
vote
2answers
37 views

Regex problems Java

I am trying to match the following pattern in a string and extract it as a substring. The pattern always follows <D-10-helloworld-84> The 'D' can either be 'D' or 'E' but nothing else. the ...
0
votes
2answers
40 views

Saving a date of type string into a database as type Date

I need to save a couple of dates into a database in Java. These dates are first received as strings. How do I convert them and save them as Date in the database? I was planning to use a STR_TO_DATE ...
2
votes
2answers
30 views

SimpleDateFormat possible error in method parse

I receive a string that represent a date, I need convert this string to date, and validate that the string is a valid date. I receive the string 33-12-2013 a the parse method return a date ...
-2
votes
4answers
60 views

void error in Arrays.sort() in java

String text1 = "check"; char c[] = Arrays.sort(text1.toCharArray()); Output: error: incompatible types char c[] = Arrays.sort(text1.toCharArray()); required: char[] found: void ...
0
votes
3answers
70 views

If statement not working in string search

The task The function named getKey1() is supposed to return the substring which occurs the maximum number of times in a string. What have I done? public class Proc { public static String ...
0
votes
3answers
54 views

Java String Concatenation using Array

I know that there exists a package that supports handling biological information such as Biojava , but I want to make a simple code which will convert a DNA sequence into a complement sequence of it ...
-5
votes
0answers
44 views

Eclipse error :- String can not be resolved to a type [on hold]

I am working on a project in Eclipse. I just wrote my first class. However it does not seem to identify String as a type and gives a red under-line saying - String can not be resolved to a type . I ...
0
votes
2answers
42 views

Interpret java strings containing integer literals (dec, hex & oct notation) as integer values

I'd like to convert string representations of integers to actual integer values. I do not know which radix/base is being used beforehand, so I cannot simply rely on methods/constructors that take the ...
3
votes
4answers
100 views

Search string in two dimensional string array java

I have a two dimensional string array look like this: The first column contains characters of many strings, other columns are extra data for character. I want to search a string (maybe change to ...
2
votes
5answers
46 views

Get rid of anything outside brackets in string java

I have the following string 34rf;43jh<helloworld>guge73g34/ I basically want everything outside of "<" and ">" to be removed from the string so that it returns: <helloworld> How ...
0
votes
1answer
47 views

Java String split method [on hold]

I was working on a project and I needed to split Strings, but I had some trouble with it: So, as an example: String text = "cat(12;11,42;654)" String[] split = text.split(something here); So, I am ...
0
votes
4answers
39 views

How to name call methods with the contents of a string

How do I call a method with the contents of a string? I have say 4 strings: swimming football rugby hockey And I also have 4 methods called: swimming football rugby hockey I have a listview with ...
-5
votes
0answers
43 views

Java - Write a Rock, Paper, Scissors Game? [on hold]

I am stuck and I have no idea how to make it work and I can't figure it out. Please help me Your input from the command prompt should be a string value instead of an integer values Use String ...
2
votes
1answer
36 views

java replacing back strokes with other characters

I have come across this little problem. String fileAdress = "c:\red\"; System.out.println("Peach " + fileAdress); fileAdress = fileAdress.replaceAll("\", "\\\\"); ...
0
votes
2answers
58 views

Removing repeated characters, preserving order [duplicate]

I'm trying to write a code that takes in a String and removes repeating characters in that String. String utenRepetisjon(String tekst) { String b; char[] tekstArray = tekst.toCharArray(); ...
1
vote
1answer
22 views

Strip non-printable characters using Hadoop Map-Reduce

I am trying to process a HDFS file which has non-printable chracters. I wish to strip these characters out using MapReduce. I have tried using Pig TextLoader and MR TextInputFormat (IN MR program), ...
-8
votes
4answers
59 views

String to integers [duplicate]

how can I convert IPv4 to four several integers.? Here is some example: This is an input: 158.195.16.154 And I want output like this: int a=158; int b=195; int c=16; int d=154; Thx for the ...
0
votes
1answer
52 views

Java Performance optimise replacing one String with another, repeatedly

Im working on a HttpServlet extension (plugin) to a CMS, and its task is to filter the HTML response. In my filterResponse method I get the requested text/html in a String, which is one of three ...
5
votes
6answers
84 views

How many memory locations will it take to have a sting concatination?

How many memory locations will it take to have a sting concatination? String myStringVariable = "Hello"; In following two statements : String s = "ABC" + "Hello" + "DEF"; and String s = ...
-1
votes
1answer
60 views

Write to file using ObjectOutputStream without overwriting old data [duplicate]

I need to write strings on an file on eclipse without overwriting old strings. The function would be something like: create a string, save it on the file, create another string, save it on the file, ...
0
votes
1answer
27 views

How to get String data from a running JVM by using AJAX to display it on html?

This is my JVM code which loops forever. public String getValue(String fieldName) { String value = null; if (_record != null) { if (_active) { if (_hasData) ...
6
votes
4answers
106 views

How to detect whether String.substring copies the character data

I know that for Oracle Java 1.7 update 6 and newer, when using String.substring, the internal character array of the String is copied, and for older versions, it is shared. But I found no offical API ...
0
votes
4answers
50 views

Error in string format

I have a method that prints out the total price as a double after calculating the charge and adding a fee to it. public static String printWarehouseCharge(Warehouse w[]) { String wc = ""; ...
0
votes
7answers
55 views

I want to parse String into java date object [duplicate]

Hello i have date in this format 2013-10-31T19:00:00Z now i want to display this date into yyyy/mm/dd this format.i have used this code but its giving me exception kindly help me String ...
2
votes
1answer
37 views

How to compress many strings across a data structure?

I have a 500GB collection of XML documents that I'm indexing. I'm currently only able to index 6GB of this collection with 32GB of RAM. My index structure is a HashMap<String, ...
0
votes
1answer
35 views

I can't get replace / replaceAll to work

I need to show data from database that supposed to be shown: in the html: Beh&#228;lter in the browser: Behälter but instead, I got data like this: in the html: Beh&amp;#228;lter in the ...
0
votes
1answer
42 views

Recursive Java RLE Decompression Method [stackoverflow error]

I am trying to write a program in Java that decompresses a compressed RLE statement using recursion, but I am continuously getting stack overflow errors and I do not know why. Here is what I wrote ...
0
votes
3answers
38 views

Direct String quicker than a String Variable?

final String string1 = "somestring1"; for (int i = 0; i < 30; i++) { final String string2 = "somestring2"; if (string2.equals(string1)) { // Using variable // do ...
0
votes
1answer
51 views

Java word finder [on hold]

I have a text file , in which I have random number of sentences(lines) like that: Phil has 10 dollars and blue hat David has 5 dollars and white hat John has 12 dollars and blue hat Phil has 10 ...
1
vote
1answer
60 views

Compare files string by string

I have two files: Grader.getFileInfo("data\\studentSubmissionA.txt"); Grader.teacherFiles("data\\TeacherListA.txt"); Both contain a list of math problems, but the TeacherList is unsolved in order ...
2
votes
6answers
69 views

Shifting characters within a string

String newStr; public RandomCuriosity(String input){ newStr = input; } public void shiftChars(){ char[] oldChar = newStr.toCharArray(); char[] newChar = new char[oldChar.length]; ...
1
vote
5answers
65 views

Split strings with an “Enter”

I have code that splits a string into 3 strings, then prints them. I want each one to be separated by the equivalent of an "Enter". Here's the code: String accval = text; try { ...
2
votes
7answers
75 views

In Java, is a String an array of chars?

I want to know, if a String is a collection. I have read around but am still quite confused.
-1
votes
2answers
26 views

Can a string be converted to a string containing escape sequences in Java?

Say I enter a string:- Hello Java! I want the output as:- Hello\nJava! Is there any way in which I could get the output in this format? I am stuck on this one and not able to think about any ...
0
votes
2answers
44 views

Find an String with some keys in java

Consider a map as below: Map("PDF","application/pdf") Map("XLSX","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") Map("CVS","application/csv") .... There is an export method ...
0
votes
5answers
52 views

Java String.split error

My method successfully takes a binary expression tree and turns it into prefix, postfix, and infix notation. However, due to the accuracy of the final string, it must be exactly equal. So before I ...

15 30 50 per page