It's not clear what exactly you're trying to do (maybe you can elaborate), but the RandomAccessFile class can update data in the middle of a file (assuming the file has a fixed, known format).
If you want to get rid of the previous contents altogether, then "StandardOpenOption.APPEND" is probably not the right option to use :-)
sorry for last comment basically if i remove append the content is not cuming full in file i want remove existing content and overwrite the new content in same file rajveer7 hope You got my point
Don't use Files.write() with a byte array parameter if you're working with textual data. Split your HTML into separate lines first. You can also perform the delete and write in one step:
if(wb1.getLocation().contains("&ini=")){
JOptionPane.showMessageDialog(null, "got "+wb1.getLocation());
String html = (String) wb1.executeScript("document.documentElement.innerText");
System.out.println(html);
content is coming from this part
and string output is coming like this |[server]||[app]|host_name=pmms.ankiti.com|ns=|session_name=pmms_ankiti_com|lang=en||[portal]|host_name=mms.ankiti.com|ns=|locale=en|domain=pmms.ankiti.com|ent_id=|app=mm-pmms|sec_ns=ankiti|sec_conf=sec-staff-lgc|sec_permissions=mms.ankiti.com|locales=mmstech|email=service@pressmonitor.com|email_name=Press Monitor|email_cc=news@ankiti.com||[shell]|id=wssoj75f2|host_name=pmms.ankiti.com|domain=ankiti.com|ent_id=|locale=|head= |header_bar=
APPEND has nothing to do with your problem. You don't want to append lines, you want to write them from the start. There's likely something else going on.
Write a small program that uses my suggestion, that displays the problem you're having. Hardcode the HTML you're having the problem with in the application, so we can just run your application to see what's going on.
The issue you are having is with the writing to the file (something like that, I'm really not clear what the goal is if I'm honest).
So it should be possible to show that it's a File writing issue by extracting the file writing code and seeing how that works for different HTML data.
Now, should that not cause the issue then it is likely not the file writing that's the issue here.
That's when you look at the source data and see if there's something up with that.
Neither of those require your full code to deal with.
I don'e see why you can't stub out most of the other stuff.
That's how to break down an issue like this, otherwise there's so much going on that it's hard to isolate where the actual issue lies.
but thats come when i load my application in webEngine() because that come in application only through db and i dont have the access of db so i can only provide the code with loading the application url in webEngine()?
How do you run your program? If it's in an IDE, you can put a breakpoint after the line that assigns a value to your html variable. Then inspect the value of the variable. If you're running from the command line, use System.out.println() to write the variable to the standard output, and pipe the output to a file.
IM ALREADY PRINTING THE OUTPUT THIS IS THE CODE
String html = (String) wb1.executeScript("document.documentElement.innerText");
System.out.println(html);
THATS WHY IM GETTING IT IN CONSOLE
The text that you posted above that gets printed to console, is that the complete text you expect to be in the file, or is there still something missing?
Well, the obvious (to me) difference is that you are sending the output as a byte[], including the character set, which could well be mucking the data up, whereas your println() call to log just uses the String directly, with no messing about.
So, how about trying to print the byte[]? You'll need to use out.write instead of out.println.
I would try it out myself, but I have no idea what the actual data looks like that you are expecting to output. The earlier post doesn't clearly identify what you expect and what you get.
Also, there's no guarantee it's not around the encoding of the original html, so copy/paste from here wouldn't show that.
k thanks dave i had tried with System.out.write(html.getBytes(StandardCharsets.UTF_8)); also its also printing the complete content to the console. but the main prob is in saving in .ini file
//second time saving the file but its save after old content only its not replacing old content or file with new
|[server]||[app]|host_name=pmms.ankiti.com|ns=|session_name=pmms_ankiti_com|lang=en||[portal]|host_name=mms.ankiti.com|ns=|locale=en|domain=pmms.ankiti.com|ent_id=|app=mm-pmms|sec_ns=ankiti|sec_conf=sec-staff-lgc|sec_permissions=mms.ankiti.com|locales=mmstech|email=service@pressmonitor.com|email_name=Press Monitor|email_cc=news@ankiti.com||[shell]|id=wssoj75f2|host_name=pmms.ankiti.com|domain=ankiti.com|ent_id=|locale=|head= |header_bar=