Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Didattica > Corsi N - Z > Programmazione > [JAVA] Aiuti
Pages (4): « 1 2 3 [4]   Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.84 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:57:33 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

non l'ho provato, ma testalo in questo modo:

code:
FileInputManager in = new FileInputManager(file); String testo = in.readLine() + "\n"; while(in.readLine() != null){ testo += in.readLine() + "\n"; }

__________________
http://www.twitter.com/0m4r

07-04-2005 17:48
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
ste182
.arcimaestro.

User info:
Registered: Oct 2004
Posts: 258 (0.03 al dì)
Location:
Corso: informatica
Anno:
Time Online: 2 Days, 5:06:07: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

così mi salta la seconda riga, ovvero mi stampa:

ciao ciao, come va?
pippo

il file contiene:

ciao ciao, come va?
prova
pippo

__________________
Live Fast, Die Fun

07-04-2005 18:07
Click Here to See the Profile for ste182 Click here to Send ste182 a Private Message Find more posts by ste182 Add ste182 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.84 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:57:33 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by ste182
così mi salta la seconda riga, ovvero mi stampa:

ciao ciao, come va?
pippo

il file contiene:

ciao ciao, come va?
prova
pippo


sono un babbo io, ho sbagliato. Cmq cosi dovrebbe essere gia meglio:
code:
FileInputManager in = new FileInputManager(file); String s = ""; for(String t = in.readLine()+"\n"; t!=null; t=in.readLine()+"\n"); s +=t; System.out.println(s); }

__________________
http://www.twitter.com/0m4r

07-04-2005 18:10
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
ste182
.arcimaestro.

User info:
Registered: Oct 2004
Posts: 258 (0.03 al dì)
Location:
Corso: informatica
Anno:
Time Online: 2 Days, 5:06:07: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

..ancora peggio ehehehe

__________________
Live Fast, Die Fun

07-04-2005 18:16
Click Here to See the Profile for ste182 Click here to Send ste182 a Private Message Find more posts by ste182 Add ste182 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
ste182
.arcimaestro.

User info:
Registered: Oct 2004
Posts: 258 (0.03 al dì)
Location:
Corso: informatica
Anno:
Time Online: 2 Days, 5:06:07: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

ora ho fatto così:

String riga = in.readLine() + "\n";
do
riga += in.readLine() + "\n";
while(in.readLine() != null);
in.close();

e mi stampa tutto giusto tranne che sull'ultima riga, mi mette "null" al posto di "pippo"

__________________
Live Fast, Die Fun

07-04-2005 18:18
Click Here to See the Profile for ste182 Click here to Send ste182 a Private Message Find more posts by ste182 Add ste182 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
darkAntAreS
...bloup will rule you...

User info:
Registered: Jun 2004
Posts: 267 (0.03 al dì)
Location: gorgonzola(MI)
Corso: informatica
Anno: x
Time Online: 3 Days, 14:49:45 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

tentare non nuoce :D

code:
FileInputManager in = new FileInputManager(file); String riga = ""; while((riga = in.readLine()) != null) { System.out.println(riga); }

__________________
"Ash nazg durbatulûk, ash nazg gimbatul, ash nazg thrakatulûk agh burzum-ishi krimpatul"

07-04-2005 19:03
Click Here to See the Profile for darkAntAreS Click here to Send darkAntAreS a Private Message Find more posts by darkAntAreS Add darkAntAreS to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
ste182
.arcimaestro.

User info:
Registered: Oct 2004
Posts: 258 (0.03 al dì)
Location:
Corso: informatica
Anno:
Time Online: 2 Days, 5:06:07: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

il problema è che al posto di stampare la riga, dovrei memorizzarla in una variabile e concatenare ogni volta la riga successiva che leggo.... in pratica devo leggere tutto il contenuto del file e metterlo in una variabile...

__________________
Live Fast, Die Fun

07-04-2005 21:50
Click Here to See the Profile for ste182 Click here to Send ste182 a Private Message Find more posts by ste182 Add ste182 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
nfast
.precettore.

User info:
Registered: Sep 2004
Posts: 95 (0.01 al dì)
Location:
Corso: Informatica
Anno: primo
Time Online: 18:00:55 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by darkAntAreS
tentare non nuoce :D

code:
FileInputManager in = new FileInputManager(file); String riga = ""; while((riga = in.readLine()) != null) { System.out.println(riga); }


prova così
code:
FileInputManager in = new FileInputManager(file); String riga = ""; String testo = ""; while((riga = in.readLine()) != null) testo += riga;


in questo modo concateni il tutto nella variabile testo.
ciao

07-04-2005 22:06
Click Here to See the Profile for nfast Click here to Send nfast a Private Message Find more posts by nfast Add nfast to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
ste182
.arcimaestro.

User info:
Registered: Oct 2004
Posts: 258 (0.03 al dì)
Location:
Corso: informatica
Anno:
Time Online: 2 Days, 5:06:07: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

ok funziona! grazie mille:D

__________________
Live Fast, Die Fun

07-04-2005 22:12
Click Here to See the Profile for ste182 Click here to Send ste182 a Private Message Find more posts by ste182 Add ste182 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Gusher
Splinter fun club

User info:
Registered: Jan 2003
Posts: 475 (0.06 al dì)
Location: Ovunque
Corso: Informatica
Anno: Done
Time Online: 15 Days, 22:06:15 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by ste182
il problema è che al posto di stampare la riga, dovrei memorizzarla in una variabile e concatenare ogni volta la riga successiva che leggo.... in pratica devo leggere tutto il contenuto del file e metterlo in una variabile...


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

class Test
{
public static void main(String args[])
{
try{
String myLine;
String myContent="";
BufferedReader myBuffer = new BufferedReader (new FileReader("c:\\text.txt"));
while((myLine=myBuffer.readLine())!=null)
{
myContent+=myLine+"\n";
}

/*Stampa il contenuto del file*/
System.out.println(myContent);
}
catch (IOException e){
System.out.println("Eccezione: "+ e);
}
}
}

07-04-2005 22:13
Click Here to See the Profile for Gusher Click Here to See the Blog of Gusher Click here to Send Gusher a Private Message Find more posts by Gusher Add Gusher to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
lino
.precettore.

User info:
Registered: Jun 2003
Posts: 96 (0.01 al dì)
Location: lodi
Corso: informatica
Anno: terzo
Time Online: 2 Days, 1:25:20 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Se qualcuno ha bisogno di una mano con java per il prossimo appello, mi faccia sapere con un pm. Ciao a tutti

20-04-2005 08:53
Click Here to See the Profile for lino Click here to Send lino a Private Message Find more posts by lino Add lino to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 15:55.    Post New Thread    Post A Reply
Pages (4): « 1 2 3 [4]   Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.104 seconds (64.27% PHP - 35.73% MySQL) con 24 query.