I have simple code to execute commands from cmd in windows xp
I would like to display output in IE and Chrome browser instead of notepad
Thank you for the tips,
PrintWriter output = new PrintWriter(
("C:\\Documents and Settings\\jszpakow\\Desktop\\ping.txt"));
thank you very much for advices. I'm new here so I know in the future I should be more specific. it's nothing wrong with notepad++, or browser as a text viewer (however when I create html text is not raw like in notepad)
My idea was not to open each time CMD and copy ping output to my case notes which is in web browser system (based on Liferay)
My problem is that I need to paste this ping output in my case notes in specific field textarea in the browser tab, but each time url and textarea ID is different.
(source html) textarea id="xx:caseViewForm:caseViewTabView:caseNotesInput"
so maybe I can send output to buffer and paste it using ctrl + v
the other thing when I tried to use xml or docx file as output, it creates them but I can't open it. (I'm receiving message corrupted file)
I am assuming that you dont want to write some sort of web server or web services. If your just double clicking on a file to see its output, rename the output textfile to .html
You can even print out html tags and format the text to make it look nicer.
PrintWriter output = new PrintWriter( ("C:\Documents and Settings\jszpakow\Desktop\ping.html"));
If you mean that you'd like to use a web browser as a text file viewer, they can do that by default. The URL format is file://$path, so in this case:
file://C:\Documents and Settings\jszpakow\Desktop\ping.txt
Renaming the file extension to .html would make your browser the default viewer, but you'll loose formatting on raw text.
However, if you mean you'd like to make the output available to other people on the web, you'd need a publicly-accessible web server to upload to. This means you'd either have to install and configure WAMP on your local machine, or get a web hosting account and FTP the file.
Whats wrong with notepad? You haven't used Notepad++, have you? Use it, it's will be far better than any browser.
Related
I have web-application.
When I follow a link:
http://..... document/view?type=pdf
I expect browser to show a pdf file. It works correct on Firefox and IE, but Chrome starts downloading it instead of showing.
Here is the code:
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "inline; filename=test;");
OutputStream out = response.getOutputStream();
out.write(pdfByteData);
out.flush();
What could be the problem? May be it is because of my local chrome settings or something else? I have no idea.
Try to install the pdf plugin in chrome using the following link
https://support.google.com/chrome/answer/142056?hl=en
How Browsers Work With File Downloads
Usually when a user goes to a file URL (for example: a download link), the file will show in the
browser if the browser supports it. Image files like jpg, png, gif
etc. will almost always show in the browser. Archive files like zip,
tar, gzip etc. will always be downloaded. Some file types show up in
some browsers but not others depending of if the browser can read the
file or not. For example, Internet Explorer (IE) will usually try to
show Microsoft Word files (doc and docx) in the browser, while most
other browsers will download it. Google Chrome has its own PDF
converter and it will try to convert a PDF file and render it in the
browser.
The key thing to understand is that some browsers maybe able to read a
particular file type based on the addons you have installed for that
browser while others may not be able to. If a browser can read the
file type it will show it in the browser. If the browser cannot read a
file type it will force a download to the hard disk. Usually this is
not an issue since the users can save the file to there computer after
it is shown in the browser.
Just use HTML command, this what i did to my website :
Click Here to view the PDF file
works in every browser !.
I am using JNA with Java to find some properties about open windows on a Windows machine desktop. I am trying to find a way to get the file being accessed by an arbitrary windowed application. For instance, say I get information regarding the window of an open pdf document in adobe. I want to be able to get the filepath of the pdf document displayed in the window.
I know about the GetWindowModuleFileName() method, however this gets you the filepath of the executable of the application, i.e. 'javaw.exe'. If you have 'my.pdf' open in adobe, I'd like to get the filepath of this document, i.e. 'C:\...\my.pdf'.
I've done some searching around (on this site and others) and haven't found anything yet on this in particular.
thank you for your time, -Kevin
If you know the process ID, you can get the list of all files currently opened by the process using Handle utility. However, it depends if adobe reader continues to keep the file open or closes it after reading it completely.
I have a JSF Web application, and at some point i present the client a big chunk of information, I want to have a save as link, that allows the client to save this information on his computer as a .txt file.
Information on how to achieve this or a good tutorial would be great.
Does this work for you? You probably would need to set the ContentType to "application/octet-stream", otherwise the client's browser will display your text file instead of offering the option to "Save as".
I believe your best bet may be to have that link actually generate an Ajax call to generate the text file and set it as the src attribute of an iframe on the page. That will trigger (I think) the file download box.
I am using PD4ML to print a PDF file and It is working fine. Now the thing is I want show that file directly in acrobat with out save that file. In Local version I am using
Program.launch(getFilePath());
It is working fine but in web version I am unable to get that.
Can you please suggest me, Its very helpful.
Thanks,
Vara Kumar PJD
The web isn't like your desktop, so forget about doing things on the web the way you do them on the desktop without at least some effort.
Know that you don't read PDF files on the web using Acrobat without a browser plugin. Or some other reader like Foxit Reader.
My recommendation: forget about doing it this way. Either server your pdf as a file that can be downloaded, or read this SO post about embedding PDF in HTML.
I don't think this will be possible: "showing file outside browser in an application without user consent" because that is how browser are made for security reason. The best you can do is, as pointed in earlier post is by darioo, to show file in browser or prompt user to download/open.
I want to open a webpage (whose URL is given as the commandline argument) and then want to save the content of that webpage as a .txt file.
Remember, I need the .txt file and not the source of the webpage.
I tried my hand with selenium and it works fine. But now I want something that doesn't open the real browser as opening the browser and loading a page in it is a time consuming task.
I want to do it in java.
By content, I mean the text (without markups) which we get when we save a webpage in IE by going to "Save As" and then selecting ".txt" as the output format of the file.
If I understand correctly your question, you want to render the page and copy the rendered text without using a navigator.
For this, you'll need a headless browser. HTMLUnit would be a good choice.
To get the text content, you could do it like this (not tested) :
WebClient c = new WebClient(BrowserVersion.INTERNET_EXPLORER_6);
TextPage tp = c.getPage("yoururl");
String content = tp.getContent();
(see Javadoc)
Hmm, I'd even code that from scratch, does not seem as a complex thing and might not be even worth adding a dependency on another library to your project:
Open a URLConnection to that URL
Get a stream from the connection, apply regex to strip out all the HTML to the data. If the page is not expected to be too large for you memory requirements :) read the page into a String then apply the regex. Alternatively, give a shoot to what's described here (I have no experience with the way described there though).
Save output to a txt.