Java and substring
Hello, I need something simmilar to "awk { print $1 }", but for java. I have a string, similar to this: word1 word2 word3 word4 word5 word6 How, can I substring first word, from every line? ...
Hello, I need something simmilar to "awk { print $1 }", but for java. I have a string, similar to this: word1 word2 word3 word4 word5 word6 How, can I substring first word, from every line? ...
I have several threads (some of which are spawned by Process X, others by Process Y, et cetera), and each thread needs to write to a file MyFile. However, if Thread T1 starts writing to MyFile first, then, when Thread T2 starts writing, it needs to wait for T1 to release the file, so that it can read the contents that were written in Thr...
Is it possible to draw EKG (electrocardiogram) graph and flashing light without using any container, if not what is the alternative? ...
In using Apache MINA, I'm sending a login request from the client, which is interpreted on the server via LoginRequestDecoder (implements org.apache.mina.filter.codec.demux.MessageDecoder). I now want to send a response (LoginResponse) that includes a success/failure code. Should I be sending the response from the LoginRequestDecoder's...
In a file I have some variables stored like this: author = {Some Author}, link = {some link}, text = { bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla}, ... Some of the variables are on multiline. After that i need to spit the every String entry into key and value, but thats not a probl...
Does anyone have a simple tool that can convert a non-escaped string to an escaped string? For example, I'm trying to paste the following data into a Java String datatype: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> I manually have to add the slashes: <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?> Then...
In Windows 7, if you change the font size via the Control Panel->Appearance and Personalization -> Display "Make text and other items larger or smaller", it adjusts not only the menu sizes, but also the text content size of apps like Notepad, Wordpad, Firefox. Is there a way to get Java to automatically scale the font without having to...
I have a Spring application running against a MySql database. I have a sales table like: +-------------------+------------------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------------+------------------------------+------+-----+---------+-----...
why doesnt any of these work: char word = "sds"; char word = 'sds'; myDog.bark("voff"); myDog.bark('voff'); in the object to myDog i have typed: void bark(char word) { System.out.println(word); } ...
let say my array has 3 integer object value= 3,4,5 i would need to create hibernate criteria that look like below criteria.add(Restrictions.and(Restrictions.not(Restrictions.eq( "stepId", new Integer(3))), Restrictions.and(Restrictions .not(Restrictions.eq("stepId", new Integer(4))), Restrictions .not(Restriction...
I would like to play background music in my J2ME game. How can I code that function? ...
I was going through this question on an SCJP preparation site . How answer A is correct? What is true about objects referenced by a, b, aa at the line labeled "// some code goes here"? class A { private B b; public A() { this.b = new B(this); } } class B { private A a; public B(A a) { this.a = a; ...
I am considering audio and MIDI application in Max (or Max for Live, really), but I am totally comfortable in Java, so something like this also seems attractive. Does anybody have any experience with Max? Is it really geared to people who do not code, or is the goofy/friendly looking UI much more efficient than writing straight code in, ...
Hi, I am using jboss, eclipse and svn together. I have to files in my test folder: test/create.jsp and test/data.txt . What I want to do is when I call my create.jsp it will update my data.txt . Obviously I want my data.txt to stay where it is as other scripts are tryong to read from it. I have tried dozens of new ways to put the path ...
So, I've been trying to figure out exactly why this isn't working but I haven't a clue. I've managed to send packets from the iPhone and receive them on my Mac. And according to tcpdump my mac is correctly sending the packets. Additionally, if I run this in the simulator it works fine. This leads me to believe that it's a network problem...
Currently I am using Castor framework to marshall the object into xml file it work greats Writer writer = new FileWriter("D:/out.xml"); Marshaller.marshal(test, writer); But now I am using javax.xml.bind to do the same thing. Writer writer = new FileWriter("D:/out.xml"); JAXBContext context = JAXBConte...
class mstLeastCountEdit { mstLeastCount reff; HttpServletRequest request; HttpServletResponse response; String msg = ""; String LcDesc=""; int i = 0; int noOfRows = 0; HttpSession session=request.getSession(true); Integer ccode=(Integer) session.getAttribute("companycode"); void updateEdit(mstLea...
The hashCode of a java Hashtable element is always unique? If not, how can I guarantee that one search will give me the right element? ...
Are there any fancy (ajaxy) chat clients that connect to a jabber server? Something that pings the server, and displays it on a web page with updates etc. ...
I have an enum which is private, not to be exposed outside of the class. Is there anyway I can do a static import of that type, so that I don't have to type the enum type each time? Or is there a better way to write this? Example: package kip.test; import static kip.test.Test.MyEnum.*; //compile error public class Test { private s...