The Artima Developer Community
Sponsored Link

Java Answers Forum
A 13 year old java programmer.Please help me

2 replies on 1 page. Most recent reply: Jan 5, 2003 9:38 AM by robbies

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
kanak

Posts: 14
Nickname: vava
Registered: Jan, 2003

A 13 year old java programmer.Please help me Posted: Jan 2, 2003 9:23 AM
Reply to this message Reply
Advertisement
Dear programmers.i was doing a simple project.ie notepad.how could we save a file in it and how could we open a file.i designed it but i am having problems with the save and open. please help me....


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: A 13 year old java programmer.Please help me Posted: Jan 2, 2003 1:42 PM
Reply to this message Reply
If you want to know how to use open and save file dialog boxes (also known as file choosers), there is a tutorial here: http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html

A fter you've gotten a File object from your dialog, you can use a FileReader to read it and a FileWriter object write your text to it.

robbies

Posts: 2
Nickname: robbies
Registered: Jan, 2003

Re: A 13 year old java programmer.Please help me Posted: Jan 5, 2003 9:38 AM
Reply to this message Reply
you should use java.io.File;

i paste some code you can refer to :

import java.io.*;
public class PushBack {

public static void main(String[] a) throws IOException
{
FileReader fr=new FileReader("test.txt");
PushbackReader pbr=new PushbackReader(fr,20);
//------------------------------------------------------ ---------
char[] arr=new char[15];
pbr.read(arr,0,arr.length);
for(int i=0;i<arr.length;i++){
System.out.println(arr[i]);
}
System.out.println("------------");
//--------------------------------------- ------------------------
char[] app={'f','f','f','f'};
pbr.unread(app,0,app.length);
for(int i=0;i<app.length;i++){
System.out.println(app[i]);
}
System.out.println("------------");
//--------------------------------------- ------------------------
char[] acc=new char[4];
pbr.read(acc,0,acc.length);
for(int i=0;i<acc.length;i++){
System.out.println(acc[i]);
}
System.out.println("------------");
}
}

maybe above code is not exact to your question
but you can understand how to read and write from a file
through it

Flat View: This topic has 2 replies on 1 page
Topic: how can i run a programme on different computers Previous Topic   Next Topic Topic: Newbie:how to get a reference out of a method

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use