Welcome Guest [Log In] [Register]
Welcome to Scisforums. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Java Help, read .dat file; medyo mahina ako sa mga ganito
Topic Started: Jul 13 2010, 08:38 PM (483 Views)
bluez_exe
Member Avatar
Pentium 4
[ *  *  *  *  * ]
mga sir, pa help naman po, anu pong gagamitin para makabasa ng isang .dat na file sa jcreator tapos yung nakuhang object eh gawing string, mahina po kasi ako pag dating sa pag basa ng mga input file. tutorial na lang po wag yung mismong code, kasi hindi ako maututo eh

thanks in advance!
Posted ImagePosted Image
Ako ang Ninja ng SCIS...wala akong sinabi
Offline Profile Quote Post Goto Top
 
malufett
Member Avatar
Pentium 4
[ *  *  *  *  * ]
try mo mga iba't ibang paraan para basahin ang isang file:

DataInputStream
Code:
 

//file is your text file or any type of file that is readable
DataInputStream dis = new DataInputStream(new FileInputStream(file));
String value0 = dis.readUTF(); //it will read all the content of the file
String value1 = dis.readLine(); //same as above but line by line


ObjectInputStream
Code:
 

//file is your text file or any type of file that is readable
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
// read object data from file into object variable (note the type cast)...
Object s2 = (Object) ois.readObject();



Scanner
Code:
 

//file is your text file or any type of file that is readable
Scanner sc = new Scanner(new File(file));
sc.nextLine();//read line by line
sc.nect(); //read every word or string.


Hope it helps... ;)
Edited by malufett, Jul 13 2010, 10:00 PM.
Posted Image
Ragnarok 3rd Jobs Development : http://svn6.assembla.com/svn/ReAM_
Accepting Paid Services
Limit Ragnarok Online(LimitRO)


The Quality Maker
powered by: rudolp
Offline Profile Quote Post Goto Top
 
bluez_exe
Member Avatar
Pentium 4
[ *  *  *  *  * ]
malufett
Jul 13 2010, 09:59 PM
try mo mga iba't ibang paraan para basahin ang isang file:

DataInputStream
Code:
 

//file is your text file or any type of file that is readable
DataInputStream dis = new DataInputStream(new FileInputStream(file));
String value0 = dis.readUTF(); //it will read all the content of the file
String value1 = dis.readLine(); //same as above but line by line


ObjectInputStream
Code:
 

//file is your text file or any type of file that is readable
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
// read object data from file into object variable (note the type cast)...
Object s2 = (Object) ois.readObject();



Scanner
Code:
 

//file is your text file or any type of file that is readable
Scanner sc = new Scanner(new File(file));
sc.nextLine();//read line by line
sc.nect(); //read every word or string.


Hope it helps... ;)
wow kuya thanks malaking tulong tonn mga codes na to, ty talaga
+1 rep ^_^
Edited by bluez_exe, Jul 13 2010, 10:11 PM.
Posted ImagePosted Image
Ako ang Ninja ng SCIS...wala akong sinabi
Offline Profile Quote Post Goto Top
 
malufett
Member Avatar
Pentium 4
[ *  *  *  *  * ]
walang anuman..basta post ka lang ng mga katanungan....may noob na sasagot sayo..haha..ang korni ko.... ^_^
Posted Image
Ragnarok 3rd Jobs Development : http://svn6.assembla.com/svn/ReAM_
Accepting Paid Services
Limit Ragnarok Online(LimitRO)


The Quality Maker
powered by: rudolp
Offline Profile Quote Post Goto Top
 
FingerLinking
Member Avatar
Pentium 1
[ * ]
ang lufettttttttttttttt............... hahaha
Posted Image

SCHOOLING -> EATING-> PLAYING GRANADO ESPADA-> SLEEPING-> BATHING-> then START THE PROCESS AGAIN :D
Offline Profile Quote Post Goto Top
 
insolence
Member Avatar
Dual Core
[ *  *  *  *  *  *  * ]
Quote:
 
//file is your text file or any type of file that is readable
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
// read object data from file into object variable (note the type cast)...
Object s2 = (Object) ois.readObject();


Ask lng po ako... myClass = (myclass) s2; pwd po ba ung ganito para iretrive ung info nung generic class object ko sa bin file?
I Played RF online and Became on of the TOP players
Then I got banned permanently cause of the DDM SK bug
I Played RF Olympic and Owned the Highlevels
Then I got banned for Camping Once
Yet the CW urge is still coming back to me
Offline Profile Quote Post Goto Top
 
malufett
Member Avatar
Pentium 4
[ *  *  *  *  * ]
insolence
Jul 24 2010, 09:56 AM
Quote:
 
//file is your text file or any type of file that is readable
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
// read object data from file into object variable (note the type cast)...
Object s2 = (Object) ois.readObject();


Ask lng po ako... myClass = (myclass) s2; pwd po ba ung ganito para iretrive ung info nung generic class object ko sa bin file?
puede as long as upper class yung Myclass mo at subclass yung s2...[Polymorphism]^^
Posted Image
Ragnarok 3rd Jobs Development : http://svn6.assembla.com/svn/ReAM_
Accepting Paid Services
Limit Ragnarok Online(LimitRO)


The Quality Maker
powered by: rudolp
Offline Profile Quote Post Goto Top
 
insolence
Member Avatar
Dual Core
[ *  *  *  *  *  *  * ]
malufett
Jul 24 2010, 09:25 PM
insolence
Jul 24 2010, 09:56 AM
Quote:
 
//file is your text file or any type of file that is readable
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
// read object data from file into object variable (note the type cast)...
Object s2 = (Object) ois.readObject();


Ask lng po ako... myClass = (myclass) s2; pwd po ba ung ganito para iretrive ung info nung generic class object ko sa bin file?
puede as long as upper class yung Myclass mo at subclass yung s2...[Polymorphism]^^
tnx po... +1 rep ^^ matalgal ko na po kasi to iniisip pero di ko pa triny hehe... tnx for verifying it
I Played RF online and Became on of the TOP players
Then I got banned permanently cause of the DDM SK bug
I Played RF Olympic and Owned the Highlevels
Then I got banned for Camping Once
Yet the CW urge is still coming back to me
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Programming · Next Topic »
Add Reply


Latest posts is now loading...Please wait...
Free Domain Name Service