Programming :: Java - Can't "Formatter.format"
Dec 24, 2010I met a trouble in Java, that is the method of "Formatter.format". The "System.out.printf" can output what I want, but why can't "Formatter.format" do that in the under way?
[Code]....
I met a trouble in Java, that is the method of "Formatter.format". The "System.out.printf" can output what I want, but why can't "Formatter.format" do that in the under way?
[Code]....
I use a NDS flashcard, mainly for Colors!
I was wondering if there's a format utility for SD cards, and something that does FAT32. because if I format my SD card in Ubuntu the normal way it stops working in my DS until I re-format in Windows.
I have download the JRE for java 1.7 in tar.gz format and extracted it. Now im left with a java folder that i have no idea what to do with. My goal is to install this JRE onto my server.
View 19 Replies View RelatedGroovy is an object-oriented programming language for the Java platform. I do not have experience in Java, only perl and shell scripts. Recently I have been asked to maintain a software written in groovy (also to make enhancements). So can I learn groovy without knowing java language. or isit I have to learn java before venturing into groovy.
View 1 Replies View RelatedIn /etc/fstab, I have a record:LABEL=/< >/< >ext3< >default,nolog< >1 1 represent a tab between 2 fieldsI just want to remove "nolog" in the 4th field (only): gsub(/nolog/,"",$4)The function work ok but it returns a record:LABEL=/ / ext3 default 1 1I know the problem is OFS=" ", but how can I keep the format of the record? (the same number of tabs, spaces).
View 5 Replies View RelatedI'm looking for some expert opinion on sed/script to work out the best way to transform one xml format into another however there are a few complexities around translation.
The extra complexities are to:
1) Take the start and stop time (YYYYMMDDHHMMSS) and convert to start time to unix time plus output the difference in seconds between both times.
2) Oid, tsid and sid are found by looking up an external file and finding the value against the channel. For example one of the lines in the file will be 2:806:27e2=channel1
Is there any way to write piped sed commands that can do this? If not, any ideas how the script should look like?
Input File
Code:
<programme start="20100910060000 +0100" stop="20100910061000 +0100" channel="channel1">
<title lang="en">This is the title</title>
<desc>This is the description</desc>
</programme>
Output File
Code:
<service oid="0002" tsid="0806" sid="27e2">
<event id="0">
<name lang="OFF" string="This is the title"/>
<text lang="OFF" string="This is the description"/>
<time start_time="1284098400" duration="600"/>
</event>
</service>
Look up file for oid, tsid and sid
Code:
2:806:27e2=channel1
2:756:37a3=channel2
5:4a06:42e5=channel3
how to implement this.
View 3 Replies View RelatedIn C++ as subjected, can anyone throw me some light on how I can generic-ly format an integer value of 1 to a string value of 0001? 11 to 0011? and 111 to 0111? simply by just appending 0 in front and limiting the length of the string to 4?
View 4 Replies View RelatedI am trying to scan in a file which has the format of
Quote:
username:password
hello:world
right now my program says
Code:
Scanner fin = null;
try
{
fin = new Scanner(new FileReader("proj1/passwd.txt"));
[Code]...
How do i correctly use delimiter to take in only the strings on one line?
I have a series of files in the format:
Which I'm trying to split using sed to have each field/value pair on on line:
So far so simple, but some of the values might have commas in them, which means they'll be split up. Is there a way to change this so that only commas not within quotes will be replaced with ? (e.g. make sed count number of " and if it finds a , after counting an odd number of " then ignore it?)
I would like to run java program on fedora10 but I am facing some problems. When I use which java command it show usr/bin/java directory. I was trying to set the java_home path in bash_profile,but there is no affect.
View 2 Replies View RelatedSituation: this semester I took an class called Introduction to Software Design with Java.It was my first intro to programming. The class had a very odd structure:1. The text was extremely high level. The first few chapters were all about object oriented programming, how objects interact, all about specification, etc (without ever talking about implementation).2. The lecture simply followed (directly) the text. And as a result was rather uninteresting.3. While highly theoretical (in that it was very high level approach), we never talked about how the computer was dealing with the information, etc.as all very "hand waving/magic" approach.
Okay so enough of the complaints:Question: This summer I'd like to dive a bit more into a language mainly out of frustration and lack of a good book. I'm thinking perhaps a lower level language.1. Would C++ be a good second language? Or should I give Java more time?2. If I am going to go with something else, is C++ sufficiently different, or should I go with C
i want to compile function c in java and compile library is success.. when i call the library in java and error is :
Exception in thread "main" java.lang.UnsatisfiedLinkError: no libfunc.so in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1689)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
[Code]....
I've just installed java (jre-6u21-linux-i586.bin) on Red Hat 4.4 AS and issued this command to check the java version: java -versionand got :bash :java: command not found
View 4 Replies View RelatedWhat is the problem? I receive this message (see in red) when i running this script (below) on bash script file:
error received:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 70 0 70 0 0 321 0 --:--:-- --:--:-- --:--:-- 0
IMAG_DOS.ZIP
[code]....
language: cOs: ubuntu 9.10 want a c or c++ program that gives the system uptime in YYYY: MM: DD HH : MM: SS format.eally it is head ditching..This is not home work or assisgnment..
View 10 Replies View RelatedI'm reading a book on assembly, and it talks a bit about the IEEE floating point format.
Quote:
To summarize, the following steps are used to convert a decimal number to IEEE single format: 1. The leading bit of the floating point format is 0 for a positive number and 1 for a negative number. 2. Write the unsigned number in binary. 3. Write the binary number in binary scientific notation f23.f22 ... f0 2^e, where f23 = 1. There are 24 fraction bits, but it is not necessary to write trailing 0's. 4. Add a bias of 127 to the exponent e. This sum, in binary form, is the next 8 bits of the answer, following the sign bit. (Adding a bias is an alternative to storing the exponent as a signed number.) 5. The fraction bits f22f21 ... f0 form the last 23 bits of the floating point number. The leading bit f23 (which is always 1) is dropped.
I made a string key-value mapping struct in C, and functions to add and remove entries. I would also like to write a function to read in this file format:
Code:
key: value
another: another value
[code]...
I want to call c exe from java source code and i want to interact with the c program during it's execution, i am able to send the parameters to c program but i am not able to interact with it.
View 3 Replies View Relatedhow can i port (easy) C++/STL to java ???
View 1 Replies View Relatedi want compile function c to java under linux. the bashfile comp :
$ cc -fpic -c $(SRCS)
$ ld -shared $(OBJS) -o module.so
i see in www.swig.org
$ comp -java example.i # line 1
$ gcc -c example.c example_wrap.c -I/usr/java/jdk1.6.0_17/include -I/usr/java/jdk1.6.0_17/include/linux # line 2
$ gcc -shared example.o example_wrap.o -mno-cygwin -Wl,--add-stdcall-alias -o example.so #line 3
error line 3 :
/usr/bin/ld: unrecognized option '--add-stdcall-alias'
/usr/bin/ld: use the --help option for usage information collect2: ld returned 1 exit status
I've had to do some code in java, a language I'm very much unfamiliarly with so please excuse my incorrect use of terms. The basic outline of my problem is I create a class object as a local within a swing button function it works fine. If I create it as a global ( with I think I need to do ) within main, then prototype it with the other swing objects at the bottom of the file when it is called it causes a host of problems. I think the easiest way is to show it.
View 2 Replies View RelatedI've just started programming at my university and I'm finding it a bit hard to get started. I've been given this for homework.Given 2 integers, a and b, print their sum. However, sums in the range 10..19 inclusive, are forbidden, so in that case just print 20The problem I'm having is that i don't know how to tell java to print 20 when the value is in that range.
View 14 Replies View RelatedI'm currently writing a program which will eventually send two 2d arrays to another machine using UDP, and then back again.
To do this I'm converting to a byte array which as far as I'm aware is the only way possible. I'm sure the problem is on the receiving program which receives like this:
Code:
DatagramSocket socket = new DatagramSocket(2000);
DatagramPacket packet = new DatagramPacket(new byte[5000] , 5000);
socket.receive(packet);
ByteArrayInputStream bin = new ByteArrayInputStream(packet.getData());
[Code].....
i am creating program that gets 'key' string and directory path and finds if key string is present in any file under given path, everything seemed OK but when i put path like "/" after 5 mins i get error : Too many opened files. I've minimalized opened File object at the same time as much as posible, tried to call System.gc(),tried to close every stream every opened file, google but i still cannot search in bigger directories.
Algorithm (mine one is much bigger so i tried to make it as small as possible:
read 'path';
read 'key'(set as public);
#&
call method get('path') {
[Code]....
why I always get that runtime error ? (I need it to search hundreds of GB so when my 40GB partition do this what will bigger one do )
I am looking to write a function to return an MD5 hash in Java but I don't want to us the MessageDigest class as I am using the J2ME framework which doesn't include it.
View 3 Replies View RelatedI'm looking for a version of Getopts for Java that isn't licensed under the GPL and accepts long options (i.e. both -h and --help). My code is licensed under BSD and I don't really want to change that just because a module uses the GPL...
View 1 Replies View RelatedI'll show the code first:
Code:
What I am after is to get the string text from the clip tags. But for now I just tested to see if it can finds the command tags and print something if it does. But it doesn't find it. Anyone knows why ?
Looks like the xml is not good, i test it with a xml validator:
Code:
i want to use java as tool in which i give an input,and on the basis of this input my specific script run. for example.... if we talk about web server.. in my java page..i have to just type my web page name...say [URL] and then enter the text...say "hi how are you"
then my script will run... in the script it itself start the service,then edit the configuration file in /etc/httpd/conf/httpd.conf
and make changes according to my input in java page... i know the scripting but i dont know how java command will execute my script...
I'm fighting my way through JAVA. But have hit another wall. Basically I need to to set paths in java so it can set/read files/director for Linux,Mac and windows.
The tutorials I'm using says to do this through the FileSystems class eg
Code:
However this reports it is missing, so a look on line says I need the headers so I set them with
Code:
This gives the following error
This has me totally confused as the tutorial shows this and checking online shows this, do I need to link in libraries or something like that?
I'm using the latest Ubuntu 11.04 and netbeans.