Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I've seen examples on how to download files programmatically, but they all use direct links, ending with .txt .mp3 .jpg, whatever. However, the link to the file I want to download isn't a direct link: it doesn't end with .extension. How can you download the file in this case?
When downloading over HTTP, the file name is usually set by the server in Content-Disposition header. If that is not present, it is up to the client to choose the file name (based on the URL or some other strategy). The extension can often be derived from the Content-Type response header. See this for some of standard content types http://en.wikipedia.org/wiki/Internet_media_type
Very stupid answer: You can just download it as all other files. Download it the same way as you do with urls with extensions.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have deployed a java web application to the tomcat in Linux server. The application used to save and retrieve files like images, xls files etc. I have specified the path in the property file of java application. Unfortunately the application is not storing the files on the location which i have given in property files. Can someone help me to correct the property file ?
base_path=\\home\\TestAppUploads\\
sectionImagePath=SectionImages
questionImages=QuestionImages
answerDescrImages=AnswerDescrImages
optionImages=OptionImages
userImages=UserImages
announcementImages=AnnouncementImages
This is just my first tought: have you tried the normal slash?
Because linux uses different slashes in path.
For example: base_path=/home/testinguser
I know this is a property file but if you want to handle this kind of problem inside your
Java code you might want to use File.separator
But it would be helpfull if you could paste here the error log
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I do program to parse html pages and store images. But I ran into a problem. This page is dynamically generated by JavaScript, it means when I download the source code of the page and there are links to pictures. Can you please advise how to bypass it? Alternatively, some příkalad to be in Java. thank you
Downloading page:
http://www.lide.cz/detail/j0YbgS6Xp7AoMAOP
That is not as easy as it seems to be at first glance. You need a headless browser engine like PhantomJS or the like that runs the Javascript and returns you the generated HTML.
See this answer to get more information on that topic.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I need to render an entire javadocs filestructure which is in plain html.
I need this to render the files using permissions. The user needs to be logged in in order to view the files.
I got a folder with .js .html and some other folders as well. I need these to be viewed by a user, but only if this user is logged in.
How do I allow Play! to return a set of these specific files, without having to modify them?
Googled quite a lot but to no avail.
Thanks in advance
You would have to create your own version of the assets controller that will enforce the auth-requirement, you could probably get it to work by just wrapping the built in Assets controller. If the javadoc is not packaged with play you could take a look at the ExternalAssets controller which can server arbitrary files from the filesystem.
If you do not already have a play app that you are including this in it would probably be easier to do this with a webserver, apache would for example allow you to do this with only configuration.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I have a Java code that writes to a file after selecting which rows to process. The problem is that by the end of the execution, the contents of the file being written on completely disappears. The weird thing is that the code works properly on Windows but doesn't on Unix. One other thing is that when only one entry is selected, the code works as it should but when more than one entry is selected, it just fails.
No other operation is performed on this file while it is being written on.
There are two possible reasons why this happens:
You forgot to close the file. Symptom: The file exists but it has length 0.
You're using PrintWriter or PrintStream and forgot to flush it.
Someone deleted the file while you were writing it.
The latter is a security feature: As long as you keep the file open, you can read and write it but no one else can access it.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I am trying to run simple static website through Jar file but not having too much luck.
The reason I want to run the website through Jar because I don't want end users to access my pages directly. For example, they should not have access to index.html page directly without actually starting my program which is built using java swing.
Things I tried:
Jar application works if I am running on the same machine where I created Jar using Eclipse because index.html page is fetching the page from local directory. which i know is wrong.
If I try using different laptop or desktop then my swing application does not open any kind of index.html through my browser.
So any suggestions?
Also, I was using Desktop.open(), Desktop.browse, getClass().getResources().getURL() .. stuff that I seen on other pages.
You need to copy your data or use a server like tomcat, jboss etc.