Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Perfect new line

 
Sathish Ramadas
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the below code to append the data at the end of the line for every time. but the problem is the new line is not correctly started . so the new line start from the middle of the line and keeps increasing for every new line. suggest me to go for a write api.

sample output:

FG|M000196 |11 GNMA |00|000156620|5618000 |MTS|010873358|FNMA SF 30 YEAR

FG|M000196 |11 GNMA |00|000156620|5618000 |MTS|010873358|FNMA SF 30 YEAR

u can see the FG | M000196 starts in the middle of the line

[ August 30, 2004: Message edited by: Joe Ess ]

[ removed code tags -ds ]
[ August 30, 2004: Message edited by: Dirk Schreckmann ]
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sathish,

I can't see the problem there. The text you describe is at the beginning of the line. Have some spaces disappeared from the start of the line in your post or something? What do you want the output to look like? If you just need to get rid of leading and trailing spaces you can use wholeString.trim().

Jules
 
Sathish Ramadas
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here it seems okay the Javaranch is doing some trailing before display the page. but when i write the details in the txt file the next line not starting exactly from the begining instead the second line starts with something like 2 tabs space and the third line with 4 tabs spaces...it keeps going like that.

suggest me a solution for the prob.
thnx.
 
Sathish Ramadas
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pls see the sample data Data 1 is one row and Data 2 is another row.

Data 1:

FG|M000196 |11 GNMA |00|000156620|5618000
|MTS|010873358|FNMA SF 30 YEAR
|NMA SF 30 YEAR |DEBT |FNMA |
|31400SR68|00696309|
S|USD|PR|14.40.14|1900-01-01-00.00.00.000000|P|8CEF1F0 |000000000|2004-07-12|2004-08-12|2004-07-15|08|+000000002010278.000|
+00000000100.9981650|+000000001012314.760|+000000001009981.430|
+00000002333.3300000|014|+00000000100.9981650|+000000001012314.760|
+000000001009981.430|+00000002333.3300000|+000000000.497443530|
+000000000999999.780|+00000000000.0000000|+000000000999999.780|N|HSBC BANK USA |001306441| |000852|10
|+000000000000000.000|+000000000000000.000|
|+000000000.060000000|2033-03-01|2003-03-01|+000000000.000000000|
+00000000000.0000000|F1
|+000000000999999.780|+000000001012314.760|+000000001012314.760|033|F/R VS
F/D |F/R vs F/D
|F/R vs F/D |CSAM | |



Data 2:

FG|M000196 |11 GNMA |00|000156620|5618000 |MTS|010873358|FNMA SF 30 YEAR |FNMA SF 30 YEAR |DEBT |FNMA | |31400SR68|00696309| |S|USD|PR|14.40.14|1900-01-01-00.00.00.000000|P|8CEF1F0 |000000000|2004-07-12|2004-08-12|2004-07-15|08|
+000000002010278.000|+00000000100.9981650|+000000001012314.760|
+000000001009981.430|+00000002333.3300000|014|+00000000100.9981650|
+000000001012314.760|+000000001009981.430|+00000002333.3300000|
+000000000.497443530|+000000000999999.780|+00000000000.0000000|
+000000000999999.780|N|HSBC BANK USA |001306441|
|000852|10 |+000000000000000.000|+000000000000000.000|
|+000000000.060000000|2033-03-01|2003-03-01|+000000000.000000000|
+00000000000.0000000|F1
|+000000000999999.780|+000000001012314.760|+000000001012314.760|033|F/R VS
F/D |F/R vs F/D
|F/R vs F/D |CSAM |

[ August 30, 2004: Message edited by: Joe Ess ]

[ August 30, 2004: Message edited by: Gregg Bolinger ]

[ August 30, 2004: Message edited by: Gregg Bolinger ]

[ removed code tags -ds ]
[ August 30, 2004: Message edited by: Dirk Schreckmann ]
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still don't get what's wrong. Both lines start at the beginning. You need to use the UBB [code] and [/code] tags to wrap your data entries. You can edit your post you know.

What happened when you tried wholeString.trim() as I suggested in my original post?

Jules
 
Sathish Ramadas
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have tried the trim() function but still the problem occurs. i am pasting the sample data with UBB code format.

Data : 1

FG|M000196 |11 GNMA |00|000156620|5618000 |MTS|010873358|FNMA SF 30 YEAR |FNMA SF 30 YEAR |DEBT |FNMA | |31400SR68|00696309| |S|USD|PR|14.40.14|1900-01-01-00.00.00.000000|P|8CEF1F0 |000000000|2004-07-12|2004-08-12|2004-07-15|08|+000000002010278.000|+00000000100.9981650|+000000001012314.760|+000000001009981.430|+00000002333.3300000|014|+00000000100.9981650|+000000001012314.760|+000000001009981.430|+00000002333.3300000|+000000000.497443530|+000000000999999.780|+00000000000.0000000|+000000000999999.780|N|HSBC BANK USA |001306441| |000852|10 |+000000000000000.000|+000000000000000.000| |+000000000.060000000|2033-03-01|2003-03-01|+000000000.000000000|+00000000000.0000000|F1 |+000000000999999.780|+000000001012314.760|+000000001012314.760|033|F/R VS F/D |F/R vs F/D |F/R vs F/D |CSAM | |


Data 2:
FG|M000196 |11 GNMA |00|000156620|5618000 |MTS|010873358|FNMA SF 30 YEAR |FNMA SF 30 YEAR |DEBT |FNMA | |31400SR68|00696309| |S|USD|PR|14.40.14|1900-01-01-00.00.00.000000|P|8CEF1F0 |000000000|2004-07-12|2004-08-12|2004-07-15|08|+000000002010278.000|+00000000100.9981650|+000000001012314.760|+000000001009981.430|+00000002333.3300000|014|+00000000100.9981650|+000000001012314.760|+000000001009981.430|+00000002333.3300000|+000000000.497443530|+000000000999999.780|+00000000000.0000000|+000000000999999.780|N|HSBC BANK USA |001306441| |000852|10 |+000000000000000.000|+000000000000000.000| |+000000000.060000000|2033-03-01|2003-03-01|+000000000.000000000|+00000000000.0000000|F1 |+000000000999999.780|+000000001012314.760|+000000001012314.760|033|F/R VS F/D |F/R vs F/D |F/R vs F/D |CSAM |

[ August 30, 2004: Message edited by: Joe Ess ]


[ removed code tags -ds ]
[ August 30, 2004: Message edited by: Dirk Schreckmann ]
 
Sathish Ramadas
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pasting the sample output again


FG|M000196 |11 GNMA |00|000156620|5618000 |MTS|010873358|FNMA SF 30 YEAR |FNMA SF 30 YEAR |DEBT |FNMA | |31400SR68|00696309| |S|USD|PR|14.40.14|1900-01-01-00.00.00.000000|P|8CEF1F0 |000000000|2004-07-12|2004-08-12|2004-07-15|08|+000000002010278.000|+00000000100.9981650|+000000001012314.760|+000000001009981.430|+00000002333.3300000|014|+00000000100.9981650|+000000001012314.760|+000000001009981.430|+00000002333.3300000|+000000000.497443530|+000000000999999.780|+00000000000.0000000|+000000000999999.780|N|HSBC BANK USA |001306441| |000852|10 |+000000000000000.000|+000000000000000.000| |+000000000.060000000|2033-03-01|2003-03-01|+000000000.000000000|+00000000000.0000000|F1 |+000000000999999.780|+000000001012314.760|+000000001012314.760|033|F/R VS F/D |F/R vs F/D |F/R vs F/D |CSAM | |

FG|M000196 |11 GNMA |00|000156620|5618000 |MTS|010873358|FNMA SF 30 YEAR |FNMA SF 30 YEAR |DEBT |FNMA | |31400SR68|00696309| |S|USD|PR|14.40.14|1900-01-01-00.00.00.000000|P|8CEF1F0 |000000000|2004-07-12|2004-08-12|2004-07-15|08|+000000002010278.000|+00000000100.9981650|+000000001012314.760|+000000001009981.430|+00000002333.3300000|014|+00000000100.9981650|+000000001012314.760|+000000001009981.430|+00000002333.3300000|+000000000.497443530|+000000000999999.780|+00000000000.0000000|+000000000999999.780|N|HSBC BANK USA |001306441| |000852|10 |+000000000000000.000|+000000000000000.000| |+000000000.060000000|2033-03-01|2003-03-01|+000000000.000000000|+00000000000.0000000|F1 |+000000000999999.780|+000000001012314.760|+000000001012314.760|033|F/R VS F/D |F/R vs F/D |F/R vs F/D |CSAM | |

[ removed code tags -ds ]
[ August 30, 2004: Message edited by: Dirk Schreckmann ]
 
Sathish Ramadas
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have used the UBB code now the above discussions what we discussed are not dispalying now. I have tried the trim () but itgives the same problem still.
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, if it looks like whitespace and it's immune to trim() then it's got to be non-breaking space ('\u00A0', '\u2007', '\u202F'). I suggest that you check this theory out. The java.lang.Character class has some useful methods. You may need to write your own trimNonBreakingSpace() method to sort it out.

Good luck.

Jules
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was having a hard time reading this thread, so I removed various code tags enclosing really long unbroken lines. It's far from perfect, as many lines are still far too long for my tiny monitor, but it's an improvement, as I see it.

If someone's particularly interested to get a look at the original formatting of some of the examples above, I'd suggest clicking the icon to reply with a quote to the thread with the example, where you can then copy the originally formatted text from the text area into your preferred text viewer.
[ August 30, 2004: Message edited by: Dirk Schreckmann ]
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the whitespace is a symptom of a different problem. You say that it increases with every line. That indicates to me that you are building wholeString in some loop and you have some buffer that you are appending to but not flushing. I'd like to see some of your code.
BTW, make sure you use String.trim() like this:

because trim() returns a new, trimmed String instance. It does not effect the original String.
I also hope you aren't calling this code:

over and over without flushing and closing the file. You should open the file once, write to it a bunch of times, then flush and close it when you are done.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!