how to set application name with line break? - java

how is it possible to make a line break for the application title? I would like to have the name on two lines under the icon amongst the installed programs on phone, like:
Harry's
App
In the xml file, setting the app_name pretty much returns a one-line title, or cuts it when the end of space is reached.

Use \n for a line break in your XML. You can use <br> too, but Eclipse might pop that up as a problem

\n didn't work for me \r\n did the trick

Related

Java tabs ("\t") not working using FileWritter

As you can see, after every text comes a tab, everything is working fine, but after third tab (see output) it generates a space not a tab.
fileWriter = new FileWriter(indexFile, true);
fileWriter.append(id).append("\t");
fileWriter.append(String.valueOf(idx)).append("\t");
fileWriter.append(String.valueOf(pageCount)).append("\t");
fileWriter.append(postal.toUpperCase()).append("\t"); <-- this one
fileWriter.append(address.toUpperCase());
fileWriter.append("\r\n");
My output:
00000347 1 1 FB-6666 DUMMY STREET 1 LAT
The problem comes after "FB-6666".
Any ideas on this?
No, it really is generating a tab - it's just that whatever you're using to view the file is deciding to handle tabs by aligning them to some boundary or other. If you make your postal value FB-6666x I suspect you'll then see a much larger space.
This isn't a problem with the file content at all.
If you want to enforce a certain number of spaces between columns, you'll need to write that many spaces. Alternatively, something else to view the file...
Tabstops don't work this way. As the wikipedia article states,
Tab stops are set manually, and pressing the tab key causes the carriage to go to the next tab stop. In text editors on a computer, the same concept is implemented simplistically with automatic, fixed tab stops.
This means the tabstop will stop at a predefined position in the textfile, not after let's say the space it would take to insert a specific amount of spaces.
It is writing a tab I promise - to convince yourself of this you should either open the resulting file in a hex editor and look at the value in that position, or add another character to the value before the tab and see how the format of the output changes.

jsp page auto removes whitespaces

I am writing lots of whitespaces as you can see the code below.
out.println("new Array('1453 12999 ALPER KOPUZ')");
unfortunately when code compiles and run the code in the screen I am able to see it as
"1453 1299 ALPER KOPUZ".
It means it auto removes whitespaces and put only one whitespace after one word.It works fine at older versions of Internet Explorer but it does show line such like "1453 1299 ALPER KOPUZ" at Internet explorer which I need to fix and our application runs on this server.
I tried css "white-space: pre;" but it is still same.
This problem makes me crazy and ate my 3 hours. I would be glad if you have any idea to fix it.
Cheers
Alper Kopuz
I guess using out.println you are writing the text as HTML on your page as response.
You need to have the text pre formatted once you print it as HTML. Try to put your text in pre tag as shown below.
out.println("<pre>new Array('1453 12999 ALPER KOPUZ')</pre>");
Let me know if this is what you were looking for.

Is it possible to automate line breaks with System.out.println()?

I am running a java program from the command line that prints a relatively long string retrieved from a file. Though the string is printed accurately (I am using System.out.println(string)), the line breaks are consistent with the size of my terminal window, which results in words being cut off in the middle and then continued on the next line. Is there a way to change the system print settings so that the string will still fit inside the window but breaks will only occur where there is white space or a hyphenation? Or is the only way to do this to build a simple GUI and use HTML? Thanks!

How to *easily* display Korean characters in a Java program

I'd like to do this:
System.out.println("안녕하세요!");
But I get a "Some characters could not be encoded using the MacRoman character encoding" popup error message when I try to compile in Eclipse. I'm running Mac OS X. Is there a way to get around that?
So, I guess I'll try using Unicode:
System.out.println((char)0xD0A4);
Which I'd like to print out '키', but instead get a '?'. I guess the command line doesn't support Unicode. But even if it did, it'd be really annoying to have to go to one of several charts (like this one) to find each character block.
Anyway, FINE! So I'll use a JLabel...
JLabel lbl = new
JLabel(""+(char)0xD0A4);
Awesome, this prints out 키! ... but I still have to look up the Unicode characters for each block. How can I easily spew out Korean characters in a program?
Switch to UTF-8, as said before.
However, instead of doing it on a per-project basis (as J-16) suggests, go through
Window -> Preferences -> General -> Workspace and change the "Text file encoding" to "Other: UTF-8".
This changes the setting for the entire workspace.
Afterwards, you can input your characters as you are used to.
The Eclipse console doesn't use unicode encoding so it can't display those. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=13865.
Try the fix mentioned here: http://paranoid-engineering.blogspot.com/2008/05/getting-unicode-output-in-eclipse.html
Just right click the file in the project view, choose properties. Change the encoding to UTF8 there.

remove indentation in source code

I use Eclipse IDE and Window Builder Pro for create window.
When I go to the source code I see a big indent text. How to delete ?
How about good old Shift + Tab?
If by "how to delete" you mean to say that you want to decrease the indentation level, try this:
Go to
Window->Preferences->general->Editors->Text
Editors
There specify the indentation level under :
Displayed Tab Width.
Additionally you can customize you formatting in Eclipse as :
Go to
Window->Preferences->Java->Code
Style->Formatter
Select the formatter and press Edit. Use whatever suits you.
Then Select the text you want to format and press Ctrl+Shift+F
If you want to fix indent only you can select lines and press Ctrl-I.
Take a look at Eclipse keys
Most likely you insert tab character which is being expanded to 8 positions in target IDE.
Change setting in Eclipse to insert 4 spaces (or whatever your style is) when tab is pressed.
Then you can try to reformat your file in Eclipse. Also, you can use sed to replace \t with 4 spaces.
If you like the way your formatter is set up for the rest of your code, perhaps telling the formatter not to work on this section would be desirable. Then you can unindent the section to make it visually appealing and not worry about it changing formatting.
Linked solution works in Eclipse 3.6.

Categories