Create a textfile in java
Hello!
I got two questions:
1) If I have a catalog called "temp" how can I controll how many textfiles there are stored in the catalogue? I want to read every textfile that is stored in there.
2) Is there any simple way to create a new textfile from a javaprogram
into a specific catalog?
Thanks for helping me// MiMa
Hello again!
Thank you for your kindness ;-)....giving me the link
Of course I know how to read/write from an EXCISTING file.... but I've never been creating a NEW file in a javaprogram. Maybe I didn't explain myself to well?
It says in the tutorials that the file I want to read/write from/to must be placed in the same catalogue so my conclusion is that the file must EXCIST before I work to the file...or Am I wrong?
And of course I've been searching in the javacommunity and in the tutorials before I posted this "fundamental question" but with no result. And I have to do this "cataloguething" otherwis I haden't made a question about it.
So what should I do?
Thank you for helping me!
Similar Messages
-
How to create a textfile dynamically(with in the loop) with given data?
Hi all,
Can anyone Please guide me how to create a text file in the given path dynamically? (with in the loop) with given data.
For example:
<%
String data1="name";
String data2="address";
for(int i=0;i<10;i++)
create the textfile at c:/test/sample.txt//name of the each file created being "sample.txt"
//contents of text file will be
data1+i; //to get name1,name2.....
data2+i// to get add1,add2........
delete(sample.txt) //to enable to create another file in the loop with same name
%>The code which Ashokan mentioned is not is not creating a file.
i used code given below to create and write into it.
But, not is writing into it. I don't konw, where i am going worng !
Code
String sample2="C:/Ash/sample2.txt";
FileWriter fw = new FileWriter(sample2,true);
BufferedWriter bw=new BufferedWriter(fw);
bw.write("EMP ID");
bw.newLine();
Please help
Regards
aSh -
Creating XML file from Java Bean
Hi
Are there any standard methods in Java 1.5 to create XML file from java bean,
i can use JAXB or castor to do so,
But i would like to know if there is any thing in java core classes,
I have seen XMLEncoder, but this is not what i want.
Any ideas
AshishMarshall JavaBean to an XML document with JAXB or XMLBeans.
-
How do I create a Principal in Java
How can I create a Principal in Java that can later be added to Websphere's Trust Map via a JAAS authentication module?
Below code is not working as it throws the following exception:
"Caused by: com.ibm.websphere.security.auth.WSLoginFailedException: javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error...."
class PrincipalExt implements Principal, java.io.Serializable {
private String userName;
public PrincipalExt()
public PrincipalExt(String userName) {
setName(userName);
public void setName(String name)
this.userName = name;
public String getName()
return userName;
Then, once I have an instance
public void login() throws LoginException {
PrincipalExt aPrincipal = new PrincipalExt();
aPrincipal.setName("someUserID");
trustMap.put("com.ibm.wsspi.security.common.auth.module.IdentityAssertionLoginModule.trusted", true);
trustMap.put("com.ibm.wsspi.security.common.auth.module.IdentityAssertionLoginModule.principal", aPrincipal);Download JFreeChart and give it a try:
http://www.object-refinery.com/jfreechart/index.html
JFreeChart is distributed for free, including the complete source code (subject to the GNU LGPL).
Regards,
Dave Gilbert
JFreeChart Project Leader -
How to create web services in java?
Hi,
I am a newbie to java webservices. Can anybody tell me how to create web services in java?
Any tutorial link or step by step doc would be useful.
Appreciate your help in this regard.
Thanks in advance.
naymo01.Creating web services in Java appears to depend highly upon the server you intend to use.
Here's a tutorial: http://java.sun.com/webservices/docs/1.6/tutorial/doc/index.html -
Created in Web dynpro Java or Web dynpro ABAP
hi all,
I have a web application running. Its UI is created either in web dynpro java or web dynpro ABAP. Is there any way by which we can find out that in which form of UI technology is it created; in web dynrpo java or web dynpro ABAP ?Hi,
I am really not sure if this is recommended..
Try some negative testing on the application. If the application crashes, the trace of the error occured will tell you what kind of development has been adopted for the Web Dynpro application.
Another hint can be the port number in the Application URL. If it is not 50xxx, and is somewht like 8xxx, it is surely Web Dynpro for ABAP.
Regards,
Alka. -
How to insert text in the middle of an existing textfile using java
Hi,
How to insert text in the middle of an existing textfile using java i/o streams??Mickie wrote:
I shudn't delete the file...Then you will have the old file and the new file - do you want that?
and I have to insert text not only at a single place ....got to do at many places in the text file!!then extrapolate on the procedure outlined in reply #1 . -
How to create and instance of Java Object from an XML Document.
Hi,
How can we use a XML Document to create an instance of Java Object and do vice versa ie from the Java Object creating the XML Document.
XML Document is available in the form of a String Object.
Are there helper class available to achieve this.
I need to do this in a Servlet.
Regards
Pramod.JAXB is part of JavaSE while Xmlbeans claims full schema support and full infoset fidelity.
If the standard APIs do all that you need well then use them. -
What are the steps to create a webservice from java
i followed the doc. of weblogic 10.3 but something is missing..i am using ubuntu
1)
i created a webservice ping.java which placed in myproject/HelloWorld directory
package HelloWorld;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.ws.BindingType;
@WebService(name="SimplePortType", serviceName="SimpleService",
targetNamespace="http://example.org")
@SOAPBinding
@BindingType
public class ping {
@WebMethod
public String main(String p){
System.out.println("sayHello:" + p);
return "Here is the message: '" + p + "'";
2) and created a build.xml and placed it in myproject folder
<project default="all">
<target name="all"
depends="clean,build-service,deploy" />
<target name="clean">
<delete dir="output" />
</target>
<path id="*my.path*">
<pathelement path="/home/suresh/bea/jdk160_05/lib/tools.jar"/>
<pathelement path="/home/suresh/bea/wlserver_10.3/server/lib/weblogic.jar"/>
</path>
<taskdef name="jwsc"
classname="weblogic.wsee.tools.anttasks.JwscTask" classpath="/home/suresh/bea/wlserver_10.3/server/lib/weblogic.jar" />
<target name="build-service">
<jwsc srcdir="HelloWorld" destdir="output/helloWorldEar">
<jws file="ping.java" type="JAXWS"/>
</jwsc>
</target>
<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy" classpath="/home/suresh/bea/wlserver_10.3/server/lib/weblogic.jar"/>
<target name="deploy">
<wldeploy action="deploy"
name="myproject"
source="output/helloworldEar" user="weblogic"
password="weblogic"
adminurl="t3://${wls.hostname}:${wls.port}"
targets="${wls.server.name}"/>
</target>
</project>
3) after that how to start weblogic and how to set any needed env or domain properties.How to publish it to server?
4) how to configure security
can i use netbeans to do all the above things?
Thanks
Sureshwhat my.path indicates in the above wsdl?
or which path i have to give there? -
Ok i have indesign CS6 and all files are stored on a 10.7.5 MAC server. This just started happening. When I open a file indesigns is creating a textfile in the same folder? I need some help on this.
Ask in the ID forum and be much more specific about your configuration. there could be any number of reasons why manifests, temp files or restore files are created.
Mylenium -
How to create a Folder using java.
Hi All,
I have a doubt. I want to create a folder using java.
Inputs are the destination where the folder should be created and the name of the folder. Plz help me in this regard.
thanks and regards,
Vincent .R.check out javadoc for java.io
File reldir=new File("NewDir");//relatively where your program runs
reldir.mkdir();
File absdir=new File("C:/NewDir");//absolute path
reldir.mkdir();
File newdir=new File(absdir,"SubDir");//defines another dir under absdir
newdir.mkdir();
Gil -
[#|2008-09-17T07:32:06.973-0500|SEVERE|sun-appserver-ee8.2|javax.enterprise.system.container.ejb.mdb|_ThreadID=58;|MDB00050: Message-driven bean [OAHMSTcpIpServer1:eaTCPIP_cmTcpIpServer_Service1]: Exception in creating message-driven ejb : [java.lang.NullPointerException]|#]
[#|2008-09-17T07:32:06.974-0500|SEVERE|sun-appserver-ee8.2|javax.enterprise.system.container.ejb.mdb|_ThreadID=58;|java.lang.NullPointerException
java.lang.NullPointerException
at com.sun.enterprise.util.InvocationManagerImpl.preInvoke(InvocationManagerImpl.java:117)
at com.sun.ejb.containers.MessageBeanContainer.createMessageDrivenEJB(MessageBeanContainer.java:670)
at com.sun.ejb.containers.MessageBeanContainer.access$100(MessageBeanContainer.java:71)
at com.sun.ejb.containers.MessageBeanContainer$MessageBeanContextFactory.create(MessageBeanContainer.java:467)
at com.sun.ejb.containers.util.pool.NonBlockingPool.preload(NonBlockingPool.java:249)
at com.sun.ejb.containers.util.pool.NonBlockingPool.doResize(NonBlockingPool.java:473)
at com.sun.ejb.containers.util.pool.NonBlockingPool$IdleBeanWork.run(NonBlockingPool.java:568)
at com.sun.ejb.containers.util.pool.NonBlockingPool$IdleBeanWork.service(NonBlockingPool.java:560)
at com.sun.ejb.containers.util.WorkAdapter.doWork(WorkAdapter.java:44)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:409)
|#]Hello,
If I make use of the @EJB annotation again a NullPointerException is risen
package videoclub;
import java.awt.Component;
import java.awt.Container;
import java.awt.FocusTraversalPolicy;
import java.util.Vector;
import javax.annotation.Resource;
import javax.ejb.EJB;
import javax.swing.JOptionPane;
import vc.bl.ClerkSessionRemote;
import vc.domain.Customer;
* @author IOANNIS_PAPAIOANNOU
@EJB(name="ejb/ClerkSessionBean", beanInterface=ClerkSessionRemote.class, beanName="ClerkSessionBean")
public class Clerk extends javax.swing.JFrame
@Resource
javax.ejb.SessionContext sessionContext;
ClerkSessionRemote clerkSessionBean = (ClerkSessionRemote) sessionContext.lookup("ejb/ClerkSessionBean");
} The line:
ClerkSessionRemote clerkSessionBean = (ClerkSessionRemote) sessionContext.lookup("ejb/ClerkSessionBean");rises the exception
the output of the client:
init:
init:
deps-jar:
compile:
library-inclusion-in-archive:
Building jar: C:\Documents and Settings\IOANNIS_PAPAIOANNOU\My Documents\NetBeansProjects\VideoClub\VideoClub-ejb\dist\VideoClub-ejb.jar
dist:
deps-jar:
compile-single:
run-single:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at videoclub.Clerk.<init>(Clerk.java:33)
at videoclub.Clerk$2.run(Clerk.java:232)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
BUILD SUCCESSFUL (total time: 2 seconds)
Yiannis P. -
Creating aVirtual directory Using java
Hai ,
I am Using windows XP Operating system, I know how to create a directory using java,
can you please suggest me a procedure to create a virtual(web share ) directory using java.
waiting for your reply
Thanks & Regards,
Naga RajuVirtual Programmer is in the to share the directory
over the Internet.No, that's a file/web server. :) I see, it's a Microsoft term. -
To create an executable of java
that it programs I can use to create the executable of java
? What is it you are looking for ? Do u wish to know how to run a java program or do u wish to know how to convert a java program to an exe ?
-
CREATING A SEARCH IN JAVA USING MYSQL QUERY
How do i create a seach in java using mysql queries. The search need to be like a good type one, whereby a category is typed and the results obtained via the search system using jtable.
Thank you.Read the tutorial on [url http://java.sun.com/docs/books/tutorial/]JDBC Database Access.
Read the tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/table.html]How to Use Tables.
Put the two together and you come up with something like [url http://forum.java.sun.com/thread.jsp?forum=57&thread=497641]this.
Maybe you are looking for
-
This is my first AppleScript Studio app so please be gentle. part of my script checks to see what applications are running. If there are applications running that shouldn't be then I want an error window to appear. If the check is OK I want a differe
-
Hay. i change the screen LCD in IPAD 2 3G but i don't know what happen. She was working and every thing it's ok. One time i turn off the ipad and turn on more time, i don't see good in LCD the brightness is to low and i can see any thing!! and i wan
-
Deleted All My Songs And I Want New Ones On But It Wont Update
Ok Well, i Deleted all my songs on porpose and Then i Put New Songs Into Music On Itunes And Then I Pluged My Ipod In and i went to music on my ipod and all my old songs are still there then i pluged it in again and then it comes up with ''DO NOT DIS
-
[Solved] Errors when starting openldev?
Hi, I used openldev for a project a while back and I know that it was upgraded since I used it. I went to start it today and I get the following errors: failed to open libtool archive "/usr/lib/openldev/libinsertinfo.la" failed to open libtool archi
-
Can't print pdf files on canon pixma mx300
pdf files won't print on my canon pixma mx300 I have • thrown out all preferences and rebooted; • reinstalled canon pixma software; • reinstalled acrobat 8; • tried printing from older version of acrobat (7); Nothing's worked. Any ideas out there on