Tag Archives: input

Getting and using an application's passed InputStream

Questions: Recently I was trying to implement the functionality of a normal terminal to a graphically designed Swing-based console project. I love how some people in here made this possible, but yet I stumbled upon another big kind of problem. Some people actually spoke about InpuStreamListener although I am not too fond of this. A… Read More »

Can I specify an input sql file with bcp?

Questions: How can I specify an input sql file with a long query when using bcp? I tried using the -i option but it keeps complaining about a command-line error with no extra information. Is this possible? Answers: As far as I’m concerned the BCP utility only supports Transact-SQL queries directly written to the command… Read More »

Nginx “No input file specified.” in a dynamic folder subdomain setup

Questions: Right, so I have this folder: /home/sites/dev/testphp/ inside this folder there’s an index.php file, with a simple echo line. I also have a /home/sites/dev/testhtml/ with an index.html file. When I visit http://testhtml.dev.ilun.no/ it works as expected. But when I visit http://testphp.dev.ilun.no/ I simply get “No input file specified.” This is my config so far:… Read More »

Saving TreeViewer state before setInput()

Questions: I’m trying to save JFace TreeViewer expansion state to refresh it after calling setInput() method. I tried getExpandedElements, setExpandedElements, getExpandedTreePaths, setExpandedTreePaths methods of TreeViewer but it doesn’t work. Object[] expandedElements = viewer.getExpandedElements(); TreePath[] expandedTreePaths = viewer.getExpandedTreePaths(); viewer.setInput(); viewer.setExpandedElements(expandedElements); viewer.setExpandedTreePaths(expandedTreePaths); Answers: You need to make sure that your TreeViewer’s content provider provides objects that have… Read More »

Why does InputStream#read() return an int and not a byte?

Questions: Why does InputStream#read() return an int and not a byte? Answers: Because a byte can only hold -128 until 127, while it should return 0 until 255 (and -1 when there’s no byte left (i.e. EOF)). Even if it returned byte, there would be no room to represent EOF. A more interesting question is… Read More »

Java JTextField with input hint

Questions: I would like to add a hint value to my JTextField. It should look like Firefox rendering of <input type=”text” title=”bla”>. This creates a edit field with the text ‘bla’ in the background. If the textbox has focus the title-text disappeares and just reappears if the user leaves the editbox without text. Is there… Read More »

Reading InputStream as UTF-8

Questions: I’m trying to read from a text/plain file over the internet, line-by-line. The code I have right now is: URL url = new URL(“http://kuehldesign.net/test.txt”); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); LinkedList<String> lines = new LinkedList(); String readLine; while ((readLine = in.readLine()) != null) { lines.add(readLine); } for (String line : lines) { out.println(“> “… Read More »