Proposed exercise
Create a program which asks the user for his name, his age (byte) and the year in which he was born (int) and stores them in a binary file.
Create also a reader to test that those data have been stored correctly.
Output
Solution
using System.IO;
using System;
class CsharpToJava
{
static void Main()
{
string name = Console.ReadLine();
StreamReader fileCSharp = File.OpenText(name);
StreamWriter fileJava = File.CreateText(name + ".java");
string line;
do
{
line = fileCSharp.ReadLine();
if (line != null)
{
line = line.Replace("bool ", "boolean ");
line = line.Replace("string ", "String ");
line = line.Replace("Console.WriteLine", "System.out.println");
fileJava.WriteLine(line);
}
}
while(line != null);
fileCSharp.Close();
fileJava.Close();
}
}