Posts

Showing posts with the label file

Download file in Servlet

Download file in Servlet I am trying to download a file in a Servlet to the web client. I keep on getting this error. Exception in thread "Thread-5" java.lang.NullPointerException at org.apache.coyote.http11.Http11OutputBuffer.commit(Http11OutputBuffer.java:347) at org.apache.coyote.http11.Http11Processor.prepareResponse(Http11Processor.java:1402) at org.apache.coyote.AbstractProcessor.action(AbstractProcessor.java:327) at org.apache.coyote.Response.action(Response.java:173) at org.apache.coyote.http11.Http11OutputBuffer.doWrite(Http11OutputBuffer.java:219) at org.apache.coyote.Response.doWrite(Response.java:541) at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:351) at org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:825) at org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:730) at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:391) at org.apache.catalina.connector.OutputBuffe...

Shell Jenkins job reading text from file with variables

Shell Jenkins job reading text from file with variables I am implementing Jenkins job in bash shell script. Jenkins jobs is using the variable AS_OF_DATE which can be used as input for users. AS_OF_DATE I also have some files on zone with text that I grep during the execution of this jenkins job. So user will start the jobs and given parameters is: AS_OF_DATE: "20180331" AS_OF_DATE: "20180331" Then during the job I grep some text from test.txt file. test.txt TEXT_FROM_FILE="This is my text, where i used ${AS_OF_DATE}" And when I do the echo of $TEXT_FROM_FILE , variable $AS_OF_DATE is not changed with the date that user added. $TEXT_FROM_FILE $AS_OF_DATE My outcome is: "This is my text, where i used ${AS_OF_DATE}" What it should be: "This is my text, where i used 20180331" "This is my text, where i used 20180331" I assume that I am not declaring the variable inside the file correctly, so my question is hot to correctly spe...

Node.js Array to text with newline

Node.js Array to text with newline I wanted to convert an array to a textfile with a newline separating each entry. I found out about an npm package called array-to-txt-file. Here is the webpage: array-to-txt-file This package claims that will concatenate every element of the array with a newline, so that every element of the array appears on its own line on the text file. So i gave it a try and while it works great it doesn't concatenate the elements with a newline. Where one element ends, another one begins. So i took a look at the source code of the package and this is the code that creates this effect. try { array.forEach(v => { if(_.isPlainObject(v)) { ws.write(`${JSON.stringify(v)}n`) return } ws.write(`${v}n`) }) Especially the ws.write( ${v}n ) part. ws.write( ) I then imported my output text file into a hex editor. In the hex editor there was dot between each element. Now, this dot was different to a regular dot. While a regula...

resolution of the original image from JPEG compression

resolution of the original image from JPEG compression JPEG compression of two images yields two 1MB and 2MB files. From these compressed files can we have an idea about the resolutions of the original images? How is that possible? thanks 1 Answer 1 The resolution of the image is the same before and after JPEG compression. JPEG compression may change the resolution of one or more components with respect to another component (usually Y). At least one component has to be sampled at the original rate so the image resolution does not change. A 50% difference in compression can result from the selection of quantization tables or (more likely) subsampling of components. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject ...

File Path - Relative Path

File Path - Relative Path I have a maven project and as part of my requirement , I need to read a file from within a Test class and thats in one of the directories inside the test folders. My proj hierarchy is like this.. src --test ---java --org --sample --- MyTestClass.java ---jmeter ---load_data.csv In MyTestClass.java I need to read the load_data.csv. My trials so far with File and Path have not yielded results file.exists() is always giving me false...How can i find the file and read it Regards Try adding the following code to your MyTestClass so that you can see what the current working directory is when you run your test: System.out.println("working dir: "+Paths.get("").toAbsolutePath()); Then you should be able to see how to build your full path. – D.B. Jul 1 at 16:45 ...