|
|
To sum it up a bit more basic, I have to get the user to enter a String (using Scanner class), The string then has to be read back in a loop until the String entered has finished, for example if i entered Scott, it would have to output S:Sc:Sco:Scot:Scott, and each time the letters are read back they have to ... |
while(hasMoreTokens) { src = nextToken; des = nextToken; cost = nextToken; String a = src + des + cost; } int [] [] array = new int[ i ] [ j ] Since I'm using tokens, I just want to take the cost and put it in a 2D array. Can I use the substring on a.substring (2,3) to get the ... |
I don't think you need lastIndexOf. You need the indexOf that takes a starting point (otherwise, you always start at the beginning of the String). Then, after the first indexOf(""), start the indexOf("") at part_start_index+15. (You may want to define a constant PART_START_TAG_LENGTH [or whatever name] instead of 15. Easier to know what the 15 means, and easier to change if ... |
|
split public String[] split(String regex) Splits this string around matches of the given regular expression. This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array. The string "boo:and:foo", for example, yields the following results with these expressions: Regex Result ... |
|
|
Hello to all Guys i am trying to use Substring Function but not able to do it properly. I am having a String str="LITTEL BY LITTEL AN ACRON SAID"; The result which i want is that i should get each and every word and i cant use substrin(0,6) then substring(7,8) this i can't use i have to use a for loop ... |
hi.. i have a txt file.which contain lot of data..in the following format i.e RTR0000001H0354 C000000000010000000000063A0000000000000{0000000000063A0000000000060{0000000000003A000000010000000000063A And i have to cut this string in tokens on basis of space(as delimeter) And then extract information from each token by applying substring.. As i know that by using StringTokenizer and subString() i can solve this issue.. But i want to know is it ... |
I am a student writing a program that has to read a HTML file and make sure all the delimiters match. I tried substring to locate the indexOf the "<">" but for the whole string, it will only give me the first occurence of each one. My first string could be . I tried tokenizer but it pulls everything outside of ... |
I was about to post that I'd bet that even a computer illiterate newb would be able to work out what "substring" meant, then realised I had a real life one sat right here. I explained the concept of "strings" to my completely non-IT literate girlfriend, and asked her what she thought a substring might be. She was spot-on |
I'm trying to understand substring() method but doesn't seem to be getting close. The method substring(startIndex,endIndex); so i think in order to get "hell" from the string "hello" then i think i'd need to say substring(0,3) , m i right ?? But the result is not "hell" it's "hel" . I mean what's wrong with it ?? According to my understanding ... |
Hi, I'm having a string whose value is " n" for example, String s = " n"; Now i want the string "\n" I used all the possibilities of s.subString (0,1) or (1,1) or (1,2) or (0,2) but i couldn't get the expected result "\n" Can anyone please advice how to get the expected result??? Thanks, Kathir |
|
|
You should write some tests to confirm that your code is correct. Try to think of lots of different inputs and make sure that the outputs are correct. You can use something like JUnit for this (it's a useful tool to learn) or just write your own if you're a newbie. Asking others to confirm that the code runs correctly is ... |
I need to write a User Defined Method which Checks if the first string is a substring of the second one. - Returns 0 if it is not a substring / 1 if it is / -1 if it is a circular substring this is an example of what it should do - abcde is a substring of blkjabcdelkjsd return ... |
|
Hi Experts, I have a requirement like this.. getting a purchase order in the variable PONUM as 00012345/abc i need to suppress all the zeros at the left side and when it reaches / then after the / terminate all the characters and return only the number, the output for the ponumber is 12345. eg: Input : 000123045/xyz Output : 123045 ... |
21. substring forums.oracle.comDear flounder, my program will read the file in and store in str. There is no split(delimiter) to determine when i should read new line. So in my case, I will need to split the string control by length. I tested the program after i posted this thread. Indeed the while loop will return false because the str length is larger ... |
|
|
Hi, I am currently using substring to extract part of a word and then compare it with a a predefine value. But when I perform a profiling on it, I notice the substring() is taking up a lot of my processing time. So, I am wondering is there another method that perform the same function as substring() but is faster. Or ... |
25. Substring? forums.oracle.comHi, I am currently working on a method that will loop through a list of words in a text file. There quite a large number of them. Each word in the text file once loaded, I will used substring to extract a portion of the word out which will be stored separately My question is there any method that will work ... |
|
Well, you could use lastIndexOf three times (with the start position option) but I think it looks more like a job for a regular expression (which could also check if the file name has the pattern you're expecting.) You might want a pattern like "[A-Z][0-9]_{6}[A-Z0-9]*_[0-9]\.txt$", depends how much these file names are expected to vary. |
This is what i have upto now and i get error message saying "out of bound". I would also like to credit Chris.Brown SPE for this code import java.util.regex.*; import java.io.*; class readlinebyline2 { public static void main(String args[]) { try{ FileInputStream fstream = new FileInputStream("c:/input.doc"); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new ... |
|
Hi , I would appreciate if somebody could help me with this. I have a text file with more than 4000 lines. I need to find a substring of 35 zeros '00000000000000000000000000000000000' and they could be in more than one place. This program should actually read from file to find those substring . If it find 35 zeros i need 10 ... |
|
|
Hi, My requirement is that i have a String with comma seperated value. Say String str=''1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20..............."; In my SQL query I need the following. OR(str1) OR(str2); Where str1 is the first 999 strings from the String str. i.e str1="1,2,3,4................999" and str2="1000,1001.......................1999" How can i do this in java.Can anyone please help me out?? Regards, priya |
|
I am tryung to build a program that will implement a substring generator. It will take a string and generate all substrings. Is this using permuate or what? For instance you take the word sun and some up with s su sun u un and n as substings Any assistance much appreciated Thanks Jonnie |
Hello, i have an interesting question :)) This is example of what i have to do.. From: kudazanovu@gmail.com Sent: Friday, December 28, 2007 9:45 PM To: kudazanovu@igorinjo.com Subject: [2008|cabaretrose] Brzo osvoji 28.12.2007. 20:44:54 Name: Ana Ivanovic Tel: 064/164-37-77 Email: anaaerobic777@yahoo.com Time: 28.12.2007. 20:44:54 From: kudazanovu@gmail.com Sent: Friday, December 28, 2007 9:04 PM To: ... |
|
No probs !!! you can comment on my approach. Basically, I would say it is kind of overkill. - First you check the format of the input String in order to determine whether your process will work. - Then, you split the input in order to extract the right-hand part of "ttl=". - Then you split this part in order to ... |
|
|
I need to load some xml file and extract some data from it. I have this code. I thing that this have to work but havent...it prints input error... Any suggestion? file is opened by this code it works ///// if (e.getSource() == openButton) { int returnVal = fc.showOpenDialog(FileChooserDemo.this); if (returnVal == JFileChooser.APPROVE_OPTION) { file = fc.getSelectedFile(); //// /// this doesnt ... |
|
i heard that using subString method is String and StringBuffer are slow Where did you hear that? All it does (in sun's implementation) is create a new string object that references the same underlying char array as the original string with a different offset and count. This is done specifically for performance. would iterating the range and appending it to a ... |
I want to read from a file.The file contain strings like Cpu(s): 0.7% us, 0.7% sy, 0.0% ni, 98.3% id, 0.0% wa, 0.3% hi, 0.0% si I want to take the value 0.7 from the file. so I use substring(9,12) a pgm import java.io.*; class FileRead { public static void main(String args[]) { try{ // Open the file that is the ... |
45. Substring forums.oracle.comyes Olew Ur right but when we give the both index for substring (Start and End) then that is much better for getting substring from a string. yeah substring(beginindex) san give the right result in case of deepi Q,but if he/she want to get some substring which is not fisrt 4 or last 4 character then substring(stratindex ,endindex ) is used,thats ... |
I am trying to color suffix and prefix of strings. For example, I would like to change the suffix substring "tion" in the string "position" to blue or red. It seems like there will be straight forward way to do so, but I could not fine it. I tried doing it using the graphics functions, g.drawString, but then I could not ... |
|
This is the question from one of Sun's e-Practice exams. I am only posting it because I believe the answer is wrong. QUESTION: A text field in a GUI allows a user to type in a string, pNum, that represents a telephone number in the following format: AAA-PPP-NNNN; where A, P, and N are digits. Assume that this string format has ... |
Hi Friend, I wnat to use substring() function in my project. I have used it now for my work purpose but i am not satisfy with that. Actually i don't know how to use it when you don't know the length of the file name. Currently i know the file name so according to that i am putting substring function like ... |
for example i have 12345 i want to insert "1" and then i get 123 This makes no sense whatsoever. Please make an effort to communicate your problem more clearely From yor "substring from the end" subject line and the example your provided, I'm going to go WAAAAAYYYYY out on a limb and wild-a$$-guess that you want to provide a number ... |
Hi, I have a string with a lot of content and I want to remove certain parts. I want to remove all occurrences of "http://.....". Each http-adress end with a space, I mean theres a space separating the adress from the rest of the content (both before and after). Any help much appreciated! |
hi i have an XML in String format. need to remove schema from it. such as everything between ...bla bla bla and the tags too. dont wanna create an xml file for input output processing etc... need some method to work directly on the string. it is a huge xml string so how do i remove different sections from it...its ... |
As you can see from the code I want to use the variable Name as a string in the substring method. Can anyone tell me if this correct? Or can it be done? NP: I will be using a NamesTest.java to enter the text Joe so that notation = Joe and Name = notation. |