473,503 Members | 6,385 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

counting string lenght

34 New Member
Could someone please help me how to count lenght string in a file?
I have input file like this:
1039387845
35368535615253
695
....
Kindly pls assist me how to count the lenght. Thank you in adv.
Expand|Select|Wrap|Line Numbers
  1. String lineA = "";        
  2.  
  3. BufferedReader inputA = new BufferedReader (new FileReader("A.txt"));                          
  4. lineA = inputA.readLine();        
  5. int lenght = Integer.parseInt (lineA);  
May 26 '07 #1
4 3163
JosAH
11,448 Recognized Expert MVP
Could someone please help me how to count lenght string in a file?
I have input file like this:
1039387845
35368535615253
695
....
Kindly pls assist me how to count the lenght. Thank you in adv.
Expand|Select|Wrap|Line Numbers
  1. String lineA = "";        
  2.  
  3. BufferedReader inputA = new BufferedReader (new FileReader("A.txt"));                          
  4. lineA = inputA.readLine();        
  5. int lenght = Integer.parseInt (lineA);  
After reading both your question and your code snippet I don't understand your
question: what exactly do you want to do? e.g. given a String line "1234", do you
want 4 as an answer (the length of that String) or 1234 (the integer value of
that String)?

kind regards,

Jos
May 26 '07 #2
javaalien
34 New Member
After reading both your question and your code snippet I don't understand your
question: what exactly do you want to do? e.g. given a String line "1234", do you
want 4 as an answer (the length of that String) or 1234 (the integer value of
that String)?

kind regards,

Jos
SORRY. I would like to count the length - '1234' as 4.
Thank you.
May 26 '07 #3
prometheuzz
197 Recognized Expert New Member
SORRY. I would like to count the length - '1234' as 4.
Thank you.
Have a look at the methods from the String class in it's API docs:
http://java.sun.com/j2se/1.5.0/docs/...ng/String.html
There's a method in there that returns the length of the String.

Good luck.
May 26 '07 #4
javaalien
34 New Member
Have a look at the methods from the String class in it's API docs:
http://java.sun.com/j2se/1.5.0/docs/...ng/String.html
There's a method in there that returns the length of the String.

Good luck.
Thank you, got it :)
May 26 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2580
by: bart plessers | last post by:
Hi, I have a counter i Now I want to derive a fixed lenght string from this counter : 1 -> "00000001" 52 -> "00000052" 12896 -> "00012896" What is the fastest way to do this?...
14
2194
by: Spare Change | last post by:
I am told that I can have a dynamic or static string array. So if I declare string dynamic; How do I add elements to dynamic and resize it ?
0
5474
by: Jean-Michel POURE | last post by:
Dear friends, I studying the possibility to port Compiere CRM from Oracle to PostgreSQL. As Compiere evolves nearly everyday in CVS, I would like to run the Oracle code without (too much)...
1
2433
by: codymanix | last post by:
How can I bind a string-Array to a DataGrid? I've already set the MappingName in the to DataGridTablestyle to "Array", but the Grid seems to display only Garbage: Lenght| -------| 13 9 3 3
1
1861
by: smeagol | last post by:
I have a varchar 255 field in the Sql. When i get the data with (string)myReader; it's trimed ie( SQL : "qwerty " (Lenght 255) c# :...
8
7802
by: cdolphin88 | last post by:
Hi, I'm reading from a .dat file and I want to know the length of the string . I' using the stringRef.length () but the compiler said there was an error `stringRef' undeclared (first use...
2
2179
by: pastir | last post by:
I have to read input from the keyboard and save it as a string (but in C strings are acctually character arrays or something?) that I am going to manipulate later. That wouldn`t be a problem except...
3
1462
by: cmdolcet69 | last post by:
What string function will cut off the last 3 characters from a string? For example: if I had the string, dim strtext as string = testcalls I want to only return the strtext as test and...
4
1262
by: Anthony P. | last post by:
Hello Everyone, I'm building an application and need to keep track of the amount of text in a textbox to make sure the user knows how many characters they have left to type. I've set the...
0
7194
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.